I want my code to constantly check if the player is inside the hitbox area. However, it stops when it checks for magnitude > 10, and I can't figure out why.
player = game.Players.LocalPlayer
repeat wait() until player:HasAppearanceLoaded() == true
while true do
wait()
local magnitude = (player.Character.UpperTorso.Position - game.Workspace.GetOn.Position).magnitude
print(magnitude)
if magnitude <9.9 then
if player and script.Parent.getOnScriptMoved.Value == false then
getOnScript = game.ServerStorage.GetOnFrame:Clone()
getOnScript.Parent = player:WaitForChild("PlayerGui")
wait()
script.Parent.getOnScriptMoved.Value = true
end
elseif magnitude >10 then
guiLocation = player:WaitForChild("PlayerGui")
if guiLocation.GetOnFrame then
guiLocation.GetOnFrame:Destroy()
end
end
end

1 comment
"repeat wait() until player:HasAppearanceLoaded() == true", player.CharacterAppearanceLoaded:Wait() exists you know, don't reinvent the wheel