local SafeZonePart = workspace.SafeZonePart
local SafeZoneGUI = game.StarterGui.ScreenGui.SafeZone
SafeZonePart.Touched:Connect(function(touching)
local humanoid = touching.Parent:FindFirstChild(“Humanoid”)
if humanoid then
SafeZoneGUI.Visible = true
end
end)
local SafeZonePart = workspace.SafeZonePart
SafeZonePart.Touched:Connect(function(touching)
local humanoid = touching.Parent:FindFirstChild(“Humanoid”)
if humanoid then
local plr = game.Players:GetPlayerFromCharacter(touching.Parent)
plr:WaitforChild("PlayerGui").ScreenGui.SafeZone.Visible = true
end
SafeZonePart.Touched:Connect(function(touching)
local humanoid = touching.Parent:FindFirstChild(“Humanoid”)
if humanoid then
local plr = game.Players:GetPlayerFromCharacter(touching.Parent)
plr:WaitforChild(“PlayerGui”).ScreenGui.SafeZone.Visible = true
end
end)
You’re modifying the wrong GUI, you’re modifying the GUI that’s given to the user when reseting or entering the game, that’s why it’s called “StarterGui”. To fix this, you need to change the variable SafeZoneGui to game.Players.LocalPlayer.PlayerGui, not game.StarterGui. Imagine that PlayerGui is StarterGui, that’s it.
Fixed Variable: local SafeZoneGUI = game.Players.LocalPlayer.PlayerGui.ScreenGui.SafeZone
Hey there! Here’s the working and slighly improved version of your script:
local SafeZonePart = workspace.SafeZonePart
local Players = game:GetService("Players")
SafeZonePart.Touched:Connect(function(touching)
local humanoid = touching.Parent:FindFirstChild("Humanoid")
if humanoid then
local SafeZoneGUI = Players.LocalPlayer.PlayerGui:FindFirstChild("SafeZone")
if SafeZoneGUI then
SafeZoneGUI.Visible = true
end
end
end)