Hi! So I made a part where you can touch it with your character and the gui will pop up. To get out of it, you press the x button on the gui and it will disappear. The problem is, the second time you touch the part, the gui will not show up again. Here is my script:
local part = script.Parent
part.Touched:Connect(function(hit)
print("started")
if hit.Parent:FindFirstChild("Humanoid") then
print("started")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.PlayerGui.Shop.ShopGUI.Visible = true
player.PlayerGui.Shop.Background.Visible = true
end
end)
changing the TouchedPart script to a localscript and placing it in StarterCharacterScripts.
which would look like this
local player = game.Players.LocalPlayer
local part = game.Workspace.Part -- Your Part's Path
part.Touched:Connect(function(hit)
print("started")
if hit.Parent:FindFirstChild("Humanoid") then
player.PlayerGui.Shop.ShopGUI.Visible = true
player.PlayerGui.Shop.Background.Visible = true
end
end)
keeping the TouchedPart script as a script but firing a remote to the client to make the GUI Invisible
local part = script.Parent
part.Touched:Connect(function(hit)
print("started")
if hit.Parent:FindFirstChild("Humanoid") then
print("started")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ReplicatedStorage.RemoteEvent:FireClient(player)
end
end)
-- LocalScript
local player = game.Players.LocalPlayer
game.ReplicatedStorage.Remote.OnClientEvent:Connect(function()
player.PlayerGui.Shop.ShopGUI.Visible = true
player.PlayerGui.Shop.Background.Visible = true
end)