Hello! I made script which appear GUI when you touch block, also I did close button and it works but if I click this close button my first script to appear GUI stop working. What's wrong?
script to appear GUI (this is in normal script)
local gui = game.ServerStorage.UniformGui
script.Parent.Touched:Connect(function (hit)
if hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
gui:Clone()
local playerName = hit.Parent.Name
local player = game.Players[playerName]
gui.Parent = player.PlayerGui
end
end)
script to close GUI (this is in local script)
script.Parent.MouseButton1Down:connect(function()
game.Players.LocalPlayer.PlayerGui.UniformGui:destroy()
end)

1 comment
You're using a server script to manipulate the GUI. You can't do that. You need to use FireClient() and use a localscript. Also capitalise the destroy() as it is deprecated.