When I try to call a GUI, the output's nil, but when I try to print something it works. Here is the code:
p = script.Parent.Position
range = 500-- the range
frame = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame
while true do
wait(.1)
plrs = game.Players:GetChildren()
for i,plr in ipairs(plrs) do
if plr.Character ~= nil then
tor = plr.Character.UpperTorso
if (p - tor.Position).magnitude <= range then
print("yay")
frame.Visible = true
else
frame.Visible = false
end
end
end
end
Thanks for the Help!

2 comments
why does it give me this: attempt to index local 'player' (a number value)?
nevermind, I found my error, Thanks for the Help!