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!
First, before I get started, I want to point a few things out:
- 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)
- 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)
- 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)
- 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!