script.Parent.Touched:Connect(function(p)
if p.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(p.Parent)
if not plr.PlayerGui:FindFirstChild("Elevator") then
script.Elevator:Clone().Parent = plr.PlayerGui
end
end
end)
This is my current script, when I touch a part it’s supposed to give me a gui (which it does) and when that gui is deleted and I go to touch the part again, it doesn’t work. Help!
How is the gui deleted, do you open the explorer window while playtesting and then delete the gui from there? If so the gui will no longer exist on the client but will still exist on the server. You have to make a server script destroy that gui so when the script you have checks for it it won’t exist.
script.Parent.Touched:Connect(function(p)
if p.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(p.Parent)
if not plr.PlayerGui:FindFirstChild("Elevator") then
local clonedGui = script.Elevator:Clone()
clonedGui.Parent = plr.PlayerGui
end
end
end)
I had a part in my simulator that made the shop gui appear you have to use a remote event because you can’t see it on the client but the server won’t know that it’s not visible
Edit:Use a remote event on any gui buttons and use a player parameter on the OnServerEvent in server script service