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 Character load in workspace check?

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

✓ Accepted answer

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)

3 comments

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

0

What do you mean it doesn't appear after the die/reset?

0

oh i fixed it! i just placed wait between GUI variable and userid check!

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