Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ClickDetecter shows GUI once, how can i fix this?

Asked by 5 years ago
Edited 5 years ago
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)
0
So here's a tip: Please show the variables when you defined them to so it would be easier for the readers/debuggers to understand what the variables mean, also, is gatherable meant to be a local or normal variable? You didn't make Gatherable a local variable, which can cause other players to control the Gui. Third, you never declare Gatherable to be false. And Lastly, Line 3 shows MouseButton i... VVickedDev 54 — 5y
0
nstead of using MouseButton1Click. The computer doesnt know what mousebutton is. It can be anything. Always use MouseButton1Click VVickedDev 54 — 5y
0
Hope this helped! VVickedDev 54 — 5y
0
MouseClick is the equal to MouseButton1Click in ClickDetector, I haven't provided the function with a If false because i didn't work on it because the problem is still there, It still doesn't work whether or not it's a Local Variable. HeroKajusa 0 — 5y
View all comments (2 more)
0
You cannot do this with GUIs. GUIs need to be done locally and therefore you can't open it using a server script., you need to fire a remote event to the GUI telling it to open. Alexander_Ashford 231 — 5y
0
Thank you mate, just what i needed to know. HeroKajusa 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
0
Why are you passing the player parameter to the client if you're not using it? DeceptiveCaster 3761 — 5y
0
Also, there really isn't a point in doing that. OnClientEvent already passes a player as its parameter. DeceptiveCaster 3761 — 5y
0
FireClient() needs a player as it's first parameter so the script knows which player's remote to fire..? Troidit 253 — 5y
Ad

Answer this question