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

Click for gui not working?(CLICK DETECTORS)

Asked by 6 years ago

Hello,so i have this GUI for spending my game's premium currency.To make it visible,i have to click on a brick to make it visible.However,when i click on it,the GUI doesn't clone into the PlayerGui and leaves no output error,i am not sure what went wrong.

Code:

script.Parent.ClickDetector.MouseClick:connect(function(player)
    local gui =script.Parent.SCIKOINSPENDER -- This is the gui that i want to make it appear
    gui:Clone().Parent = player.PlayerGui

end)

i have the following set up:

Part
     ClickDetector
     Script
     GUI

Please Help!

0
Is this a server script Gey4Jesus69 2705 — 6y
0
yea KawaiiX_Jimin 54 — 6y
0
do you have the gui enabled CodinGlitch 36 — 6y
0
I don't see any errors in the script. Try temporarily moving the screen gui to startergui and make sure you can see what you put into the gui. ax_gold 360 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

First, before I get started, I want to point a few things out:

  1. Use :Connect not :connect. connect is deprecated

so if we change that, we have:

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    local gui =script.Parent.SCIKOINSPENDER -- This is the gui that i want to make it appear
    gui:Clone().Parent = player.PlayerGui

end)
  1. Use variables and :WaitForChild, sometimes the items don't load.
local CD = script.Parent:WaitForChild('ClickDetector')
local gui = script.Parent:WaitForChild('SCIKOINSPENDE')
CD.MouseClick:Connect(function(player)
    gui:Clone().Parent = player:WaitForChildPlayerGui
end)
  1. now, make the clone into a variable to make it neater:
local CD = script.Parent:WaitForChild('ClickDetector')
local gui = script.Parent:WaitForChild('SCIKOINSPENDE')
CD.MouseClick:Connect(function(player)
    local cloning = gui:Clone()
    cloning.Parent = plr:WaitForChild('PlayerGui')
end)
  1. Your done! Now if it still doesn't work, make sure the frames and stuff inside the GUI are visible!

Good luck on your goal!

0
Thank you! It works fine now! KawaiiX_Jimin 54 — 6y
0
np BlackOrange3343 2676 — 6y
Ad

Answer this question