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

(SOLVED!) Using a click detector to open/pop-up a gui? (Nil Value)

So I have this script that's supposed to pop up/open a gui shop from a click detector and it's not working any help? Here's the script

script.Parent.MouseClick:connect(function(Clicked)
	local Clonedshop = game.ReplicatedStorage.Shop
	Clonedshop.Name = "ClonedShop"
	Clonedshop.Parent = game.Players:FindFirstChild(Clicked.Parent).PlayerGui
end)

2 answers

✓ Accepted answer

You dont need to try to find player, you can get player with Clicked not need to use game.Players:FindFirstChild(Clicked.Parent).PlayerGui

and add the :Clone() for clone the GUI.

the :connect is deprecated. use :Connect

script.Parent.MouseClick:Connect(function(Clicked)
    local Clonedshop = game:GetService("ReplicatedStorage"):WaitForChild("Shop"):Clone() -- Changed the game.ReplicatedStorage to game:GetService("ReplicatedStorage"), and changed to :WaitForChild("Shop")
    Clonedshop.Name = "ClonedShop"
    Clonedshop.Parent = Clicked.PlayerGui -- Dont need use game.Players:FindFirstChild(Clicked.Parent).PlayerGui, use Clicked.
end)

Hope it helped :)

Errors? tell-me on comments.

3 comments

0

You never told it to clone the shop you totally missed the part telling it to :Clone()

0

But with a slight modification I got your script to work.

0

oh, i forgot. edited now

assuming that script.parent is your click detector, we will clone a gui and paste it in the player gui

local plr = nil
game.Players.PlayerAdded:Connect(function(p)
	plr = p
end
script.Parent.MouseClick:Connect(function()
	local c = game.ReplicatedStorage.Shop
	local cloned_Shop = c:Clone()
	cloned_Shop.Parent = plr.PlayerGui
end)

Hopefully this works (Cloning a UI into the player gui)

1 comment

0

.

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