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

How do I make it so when a Gui disappears, you can touch the part again and it appears?

Asked by 3 years ago

I'm trying to make it so that when a Gui disappears, Ready sets to true (meaning that if you touch the part again, the gui will pop-up again). However, line 10 caused this error: "attempt to index nil with 'PlayerGui'".

Popup = script.Parent.DeleteGui ----- Your ScreenGUI's name
Ready = true
function onTouch(hit)
    local h = hit.Parent:FindFirstChild("Humanoid")
    if h ~= nil and Ready == true then
        Ready = false
        local plyr = game.Players:FindFirstChild(h.Parent.Name) 
        local c = Popup:clone()
        c.Parent = plyr.PlayerGui
        repeat wait() until game.Players.LocalPlayer.PlayerGui.DeleteGui == nil
        Ready = true
    end
end

script.Parent.Touched:connect(onTouch)

Can someone please help me fix this please?

Answer this question