Gatherable = true script.Parent.MouseClick:Connect(function(Player) if Gatherable == true then Player.PlayerGui.LootPanel.LootFrame.Visible = true end end)
This ClickDetector is supposed to open up a "Loot Frame" and when the player is done with the "Loot Frame" they can press the X button to hide the panel, however once the panel is hidden, the ClickDetector no longer makes the "Loot Frame" visible, what's the cause of this?
Code for the X button
script.Parent.MouseButton1Click:Connect(function() -- This is connected to the LootFrame script.Parent.Parent.Visible = false end)
I have fixed this issue by using Remote Events.
ClickDetector:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Event = game.ReplicatedStorage:WaitForChild("GatherEvent") Gatherable = true script.Parent.MouseClick:Connect(function(Player) if Gatherable == true then Event:FireClient(Player) end end)
Close Button:
script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.Visible = false end)
Show script inside Frame:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Event = game.ReplicatedStorage:WaitForChild("GatherEvent") Event.OnClientEvent:Connect(function() script.Parent.Visible = true end)