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

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

Asked by 1 year ago

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

Log in to vote
0
Answered by 1 year ago
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)

0
Works, TY Uniplier 83 — 1y
Ad

Answer this question