while true do
for i,plr in ipairs(game.Players:GetChildren()) do
local char=plr.Character
print("works")
if char~=nil then
local t=char:FindFirstChild("Torso")
local h=char:FindFirstChild("Humanoid")
if t~=nil and h~=nil then
if h.Health>0 then
pos1=t.Position*Vector3.new(1,0,1)
pos2=script.Parent.Base.Position*Vector3.new(1,0,1)
if (pos1-pos2).magnitude<10 then
print((pos1-pos2).magnitude)
print("I'm close enough")
game.StarterGui.ScreenGui.Enabled=true
print("Screengui should be enabled")
else
print("I'm not close enough")
game.StarterGui.ScreenGui.Enabled=false
end
end
end
end
end
wait(1)
end
What this script does is checks your distance every second, if the distance is less than 10, a screen gui should enable, but it doesen't - any idea why?

2 comments
I've tried enabling the screen gui with a script which only had the "game.StarterGui.ScreenGui.Enabled = true" row and it enables right away
The print command "I'm close enough" and "Screengui should be enabled" works on the output, but not the "game.StarterGui.ScreenGui.Enabled=true"