Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Click for gui not working?(CLICK DETECTORS)

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!

4 comments

0

Is this a server script

0

yea

0

do you have the gui enabled

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.

1 answer

✓ Accepted answer

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!

2 comments

0

Thank you! It works fine now!

0

np

This discussion is preserved as it was. New answers, comments, and votes are closed.