I made a script that moves a block to the player torso's X position. It moves to the position, but only to the original one (where the player spawned). I looked it up and came up with results of update on change and all, but once I put one of my local variables in it, the other local variable (which uses the first variable) underlined blue. Am I doing it wrong? Is there an easier solution? Here is my script
repeat wait(2.5) local victim = workspace:FindFirstChild("Player") local location = victim.Torso.Position print(location.X) wait(0.0001) repeat wait(0.000001) repeat wait(0.000001) if script.Parent.Position.X ~= location.X then if location.X > script.Parent.Position.X then print("bigger") script.Parent.Position = script.Parent.Position + Vector3.new(1,0,0) elseif location.X < script.Parent.Position.X then print("smaller") script.Parent.Position = script.Parent.Position - Vector3.new(1,0,0) elseif location.X == script.Parent.Position.X then print("found") end end until script.Parent.Position.X == location.X until 9 + 10 == 21 -- this is necessary for the fact that it will change once i get the variable situation sorted out until 9 + 10 == 21 --refer to the above comment
Please help!!! Thank you!!!
You're reading the position and setting the variable location
to remember that value. If instead of remembering it you want to actually access it, then that is what you have to actually do.
You aren't looking to remember the value, you want to keep accessing it. Either replace every instance of location
with victim.Torso.Position
or rename it to torso
and replace every instance of location
to torso.Position
.