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

Why is my script not working that removed the gui after 5 seconds?

Asked by 7 years ago

i was making a script in the server script service that removes the gui after 5 seconds the error i got is KeyDownGui is not a valid member of Startergui Heres the script


if game.ChildAdded then --- checks if the player is added wait(5) game.StarterGui.KeyDownGui:remove() end

1 answer

Log in to vote
5
Answered by 7 years ago
Edited 7 years ago

Deleting a gui from the StarterGui does not delete it for all players, I recommend removing it from each player and after they joined using the ChildAdded event.

game.Players.ChildAdded:connect(function(player)
    wait(5)
    if player and player.PlayerGui then
        local gui = player.PlayerGui:FindFirstChild'KeyDownGui'
        if gui ~= nil then
            gui:remove()
        end
    end
end)

I hope this helped!

0
Your description does not match your code. You're not 'cycling' through Players (as that implies a loop), but the end result does match OP's goal. adark 5487 — 7y
0
Originally It was going to be a for loop, but I just changed it to be worded correctly. User#9949 0 — 7y
0
dosent work dawidmcrblx 5 — 7y
0
Not quite sure what you mean. I just tested it and it works perfectly. Try placing it in ServerScriptService as a Script User#9949 0 — 7y
Ad

Answer this question