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

How to make Character load in workspace check?

Asked by
AIexR32 11
5 years ago
Edited 5 years ago

I have gui that clones yourself to playergui when player joining but when my character resetting gui dont appears

game.Players.PlayerAdded:Connect(function(Player)
local GUI = game.ReplicatedStorage.Storage.AdminBar
    ----------
    local Alex = Player.Name == "AIexR32"
    local Clemaek = Player.Name == "Clemaek"
    ----------
    if Alex or Clemaek then
        Player:WaitForChild("PlayerGui")
        GUI:Clone().Parent = Player.PlayerGui
    end
end)

i need check if character loaded in workspace then clone gui to playergui

1 answer

Log in to vote
0
Answered by
NotedAPI 810 Moderation Voter
5 years ago
Edited 5 years ago

I made an entire edit to the script. I noticed you were using usernames as authorization, using ID's are better. All explanation is in the script.

local ApprovedIDs = {} -- Your friends IDs

game.Players.PlayerAdded:Connect(function(Player)
    repeat wait() until workspace:FindFirstChild(Player.Name) -- Waits until the character is in workapce

    for i,v in pairs(ApprovedIDs) do -- loops through table
        if Player.userId == v then -- if the id in the table matches the new player
            local GUI = game.ReplicatedStorage:WaitForChild("Storage").AdminBar:Clone() -- clones

            repeat wait() until Player:FindFirstChild("PlayerGui") -- waits for playergui

            GUI.Parent = Player.PlayerGui -- parents the clone
        end
    end
end)


OR

local ApprovedIDs = {} -- Your friends IDs

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function()
        for i,v in pairs(ApprovedIDs) do -- loops through table
            if Player.userId == v then -- if the id in the table matches the new player
                local GUI = game.ReplicatedStorage:WaitForChild("Storage").AdminBar:Clone() -- clones

                GUI.Parent = Player:WaitForChild("PlayerGui") -- parents the clone
            end
        end
    end)
end)
0
Yes i know about ids but gui still does not appears after humanoid death. I think i need characteradded but i dont know how to use it. Also i made mistake when i typed characteradded (in first line of code) instead of playeradded, my bad AIexR32 11 — 5y
0
What do you mean it doesn't appear after the die/reset? NotedAPI 810 — 5y
0
oh i fixed it! i just placed wait between GUI variable and userid check! AIexR32 11 — 5y
Ad

Answer this question