Currently, I want to check if a part is moving cause I have made a train game and I want to check if the train is not moving, when its suppose to be (It got jammed or something). I have tried checking the trains previous position and its current position after 1 second and if the previous position and current difference is lesser than 20, it means its stuck. However, the trains position turns negative after reaching pass a certain point so That will no longer work.
You should try Checking the Velocity of your Train
Perferably AssemblyLinearVelocity
Do you know how to assign AssemblyLinearVelocity to a variable. I tried doing
local Xvalue = game.Workspace.Train:FindFirstChild("TrainCarraige1"):FindFirstChild("Engine").AssemblyLinearVelocity
Aint working
Nevermind, I figured out how to do it myself. Thanks for the troubles tho. Really appreciate the help
Why are you using FindFirstChild here?
local Xvalue = game.Workspace.Train:FindFirstChild("TrainCarraige1"):FindFirstChild("Engine").AssemblyLinearVelocity
FindFirstChild should only be used for conditions. Unless your using the recursive argument, there is no need for FindFirstChild if your just going to index it without checking if it exists.
That script would function the same as this:
local Xvalue = workspace.Train.TrainCarraige1.Engine.AssemblyLinearVelocity.X
I believe he already figured it out according to his post
Yes, I saw that. But I wanted to tell him that he doesn’t need to use FindFirstChild there.
Thanks for the reply/comment. I will not be using FindFirstChild.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.