Script not working

Can someone explain what is wrong with this script?

I’m a beginner scripter and I don’t know what to do.

while true do
	if script.Parent.Position.Z > -10 then
		script.Parent.Position = Vector3.new(26.322, 5.372, -10)
	end
end

And here is the video:

Thanks

Whats the problem? i cant see anything wrong? what exactly do you need help with. Could you provide a bit more info? thatd be really helpful :slightly_smiling_face:

Looking back. I dont know how. But i hadnt noticed that your loop is missing a wait(). Make sure to add “task.wait()” to your code otherwise it will run infinitely until it breaks.

while true do
	if script.Parent.Position.Z > -10 then
		script.Parent.Position = Vector3.new(26.322, 5.372, -10)
	end
task.wait()
end
1 Like

Your script infinitely hangs until Roblox stops it.

Try using RunService.Stepped instead.

local RunService = game:GetService("RunService")

RunSevice.Stepped:Connect(function()
	if script.Parent.Position.Z > -10 then
		script.Parent.Position = Vector3.new(26.322, 5.372, -10)
	end
end)