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

How do you Check to see if a Brick is moving?

Ive used

print(script.Parent.Velocity.Magnitude)

But it Continuously Said 0

Any Help?

2 answers

✓ Accepted answer

bloxxyz, the changed event does not get fired when a part's position changes.

EmperorVolvax, that only works on Non-CFramed/Un-anchored parts.

If the part is CFramed/Anchored, try comparing the part's position to it's previous position for an integer of time under the same as the speed it is being moved at.

The below example is based on the part's position being updated every second

local LastPosition = script.Parent.Position

function OnParentMoved()
	print(script.Parent.Name.." has moved!")
end

while wait(.9) do
	if script.Parent.Position ~= LastPosition then
		OnParentMoved()
	end
	LastPosition = script.Parent.Position
end

Here, try this script. It gives exact position every time it has changed, detecting movement.


--insert this inside the part that you want to check is moving script.Parent.Changed:connect(function() ---if the part has changed print("has moved or changed") wait() print(script.Parent.Position) --will give you the exact position it has moved every time it moves end)


2 comments

0

This is the script with a Changed event. Hopefully you understand it.

0

It worked in your context but not in the coding Im needing it to.

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