Ive used
print(script.Parent.Velocity.Magnitude)
But it Continuously Said 0
Any Help?
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
01 | local LastPosition = script.Parent.Position |
02 |
03 | function OnParentMoved() |
04 | print (script.Parent.Name.. " has moved!" ) |
05 | end |
06 |
07 | while wait(. 9 ) do |
08 | if script.Parent.Position ~ = LastPosition then |
09 | OnParentMoved() |
10 | end |
11 | LastPosition = script.Parent.Position |
12 | end |
Here, try this script. It gives exact position every time it has changed, detecting movement.
~~~~~~~~~~~~~~~~~
1 | --insert this inside the part that you want to check is moving |
2 | script.Parent.Changed:connect( function () ---if the part has changed |
3 | print ( "has moved or changed" ) |
4 | wait() |
5 | print (script.Parent.Position) --will give you the exact position it has moved every time it moves |
6 | end ) |