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

How to make this item clone a gui in the players PlayerGui?

So, in my game I'm trying to make it so when you click with this item, you get a gui that pops up with a few buttons on it. The script I wrote below has an error indexing nil with "playergui".

script.Parent.Activated:Connect(function()
	local ItemGui = script.Parent.AlertGui
	
    ItemGui:Clone().Parent = game.Players.LocalPlayer.PlayerGui
	
	
end)

1 answer

✓ Accepted answer
local tool=script.Parent
local player,debounce=game.Players[tool.Equipped:Wait() and tool.Parent.Name],false
local ItemGui,gui=tool.AlertGui,nil
tool.Activated:Connect(function()
if debounce then return end
debounce=true
gui=ItemGui:Clone()
gui.Parent=player.PlayerGui
end)
tool.Unequipped:Connect(function()
gui:Destroy()
debounce=false
end)

1 comment

0

Works, TY

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