Hey guys so if I wanted to make it so the SurfaceGui dissapears if I walk more than 50 studs away, how would I be able to script that? Becaus currently, my script is not working.
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local surfaceGui = script.Parent
local part = surfaceGui.Parent
local ContentHolder = surfaceGui.ContentHolder
local uiSize = ContentHolder.UIScale
RunService.RenderStepped:Connect(function()
local character = player.Character
if character then
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
local distance = (humanoid.Position - part.Position)
if distance > 10 then
uiSize.Scale = 0
else
uiSize.Scale = 1
end
end
end
end)