Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I find when a block has fallen on its side?

Asked by
Kitorari 266 Moderation Voter
8 years ago

Lets say you have a pin, and it falls over, I'm trying to get the information that it has "fallen over" to a score board.

How do I do that? Rotation/positioning? I'm dumb-founded.

Any assistance would be great!

What I got so far:

If ((Insert information here)) true then
do
Workspace.PartScoreboard.Surfacegui.Frame.Pin1.color3.new  = Color3((0, 0, 1,))
end

1 answer

Log in to vote
1
Answered by 8 years ago

I'm sure there's some brilliant, efficient, mathematical solution to this problem but because I'm not brilliant and good with math, the way I'd do it is maybe have a transparent part surrounding the top of the object and then detect whether or not it touches the floor. And then running your desired code if it does hit the floor.

Example:

local enabled = true

script.Parent.Sensor.Touched:connect(function(hit)
    if hit.Name == "Floor" and enabled then
        enabled = false
        print("Pin has hit the floor, running code.")
    end
end)

I tried this out in studio and it worked perfectly fine. I also tried another method with checking whenever the axis's of the desired object got below or above a certain degree and then running the script. But sadly the .Changed event does not work with rotation if the part is not anchored. However you might shine some light on that method yourself.

Ad

Answer this question