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

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

Asked by
IcyEvil 260 Moderation Voter
9 years ago

Ive used

print(script.Parent.Velocity.Magnitude)

But it Continuously Said 0

Any Help?

2 answers

Log in to vote
2
Answered by 9 years ago

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
Ad
Log in to vote
0
Answered by
bloxxyz 274 Moderation Voter
9 years ago

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)
0
This is the script with a Changed event. Hopefully you understand it. bloxxyz 274 — 9y
0
It worked in your context but not in the coding Im needing it to. IcyEvil 260 — 9y

Answer this question