✓ Accepted answer
Use this method:
local TestGui = script.Parent[GUI'S NAME]
script.Parent.Touched:Connect(function(t)
local plr = game.Players:GetPlayerFromCharacter(t.Parent) -- Creates a new variable contains a player value
if plr.Character and plr.PlayerGui:FindFirstChild('TestGui') then -- This will check if the player is alive and if he has the gui or not
plr.PlayerGui:FindFirstChild('TestGui'):Destroy()
TestGui:Clone().Parent = plr.PlayerGui
print('Replaced',TestGui.Name)
else
TestGui:Clone().Parent = plr.PlayerGui
print('Cloned',TestGui.Name)
end
end)
Make sure the script and the gui are inside the same parent.
If you this is too much for you, just look up at wiki.roblox.com as it has a very useful information for new people like you.
1 comment
Thx,I learned in the last 2 Weeks much about Roblox Studio,and this is helping me alot.