Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.