This is because you are using deprecated code, not using a remote event, and using StarterGUI when you use PlayerGUI. You can’t access the PlayerGui from the server and shouldn’t be.
local remote = Instance.new('RemoteEvent')
remote.Name = 'ShowGui'
remote.Parent = game:GetService'ReplicatedStorage'
local plr = game:GetService('Players').LocalPlayer
local pgui = plr:WaitForChild'PlayerGui'
local gui = game:GetService('ReplicatedStorage').Buying
remote.OnClientEvent:Connect(function(enabled)
if not pgui:FindFirstChild(gui.Name) then
gui:Clone().Parent = pgui
gui.Frame.Visible = enabled
end
end)
.
local plrs = game:GetService'Players'
local rep = game:GetService'ReplicatedStorage'
script.Parent.Touched:Connect(function(part)
local plr = plrs:GetPlayerFromCharacter(part.Parent)
if plr then
rep.ShowGui:FireClient(plr, true)
end
end)
1 comment
It's because your changing the startergui's visibility