My attempt:
magnitude = (script.Parent - workspace.Player).magnitude while true do if magnitude < 50 then wait() script.Parent.CFrame = CFrame.new(script.Parent.Position, workspace.Player) end end
workspace.Player can only be used from Server test or put your name.
I put a wait because without this little "wait(3)" you'll got an error such as "Player, a nil value" or other things like that.
I also create a variable named "numberPrinted" and printting it for beign sure it work.
don't forgot to put a wait() in you're while because you'll crash if you're torso to the part is not in 0 to 49.
you also need to put your variable "magnitude" in the while because if the player move the value of magnitude will not change and for get the magnitude you need to put the two position and not the userdata(the part or the player)
your code fix here: enjoy ;)
wait(3) local numberPrinted = 0 while true do magnitude = (script.Parent.Position - workspace.Player.Torso.Position).magnitude if magnitude < 50 then numberPrinted = numberPrinted + 1 script.Parent.CFrame = CFrame.new(script.Parent.Position) print("same"..numberPrinted) end wait(0) end