1
\$\begingroup\$

In ROBLOX Studio I need to check what part is in front of the model Freddy.

I need to set the variable called thingInFront to the part that is in front of the model Freddy so that I can decide whether I should allow him to walk through or not. This is my current code:

thingInFront = nil
if thingInFront.BrickColor == BrickColor.new('Black') then
    script.Parent.Parent.CanCollide = true
else
    if not thingInFront.BrickColor == BrickColor.new('Black') then
        script.Parent.Parent.CanCollide = false
    end
end
\$\endgroup\$
  • \$\begingroup\$ Hello, I just removed the greeting, signature, etc. from your post; those are not necessary (your name is on the post already, and we know you're here asking for help), and they actually detract from the important part of the post, which is the question. You can further edit your post or revise my edit. \$\endgroup\$ – Seth Battin Aug 5 '15 at 13:45
  • \$\begingroup\$ And while you're editing, you should include much more detail. You linked to the general page of the engine you are using, but you didn't include any of your code whatsoever except for a couple of variable names. So there is no way anyone can help you unless you include at least some way to look at your current work. \$\endgroup\$ – Seth Battin Aug 5 '15 at 13:47
2
\$\begingroup\$

Just like to say that I have little experience in the lua language

BUT,

If you take the x y z position of your model "Freddy" and the x y z position of all your other bricks, from there you could find the distance between "Freddy" and the brick and whether the color of that brick is black or not. Then when "Freddy" is a touching distance from the brick, you can allow him to pass through it or not.

Hopefully this helps.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.