Hello, I have a script that requires the distance between the character (specifically the character's torso) and an object in Workspace. However, I can't find a way to access the Player's model! The code looks a bit like this (cropped to include relevant parts only):
while wait() do local magnitude = (script.Parent.Position - game.Players.LocalPlayer.Character.Torso.Position).magnitude if magnitude < 10 then --code elseif magnitude >= 10 then --code end end
Obviously this doesn't work because LocalPlayer can only be used in LocalScripts. If anyone could find an answer, that'd be great. Thanks in advance!
Well you could put your script in a LocalScript in StarterGui(:
I suggest adding 'wait(2)', or 'game.Players.LocalPlayer.Character:WaitFirChild("Torso")' to wait until the Character's torso loads, so you don't get any unecessary errors(: