Clone() not working on client

Basically i want a gui to appear above the player, and when you join it works, but if the player reseted it doesnt work, specifically after cloning i’ve printed the parent of the clone and it says it’s nil.

local hasAccess = false
Access.OnClientEvent:Connect(function()
	hasAccess = true
	print("a")
	for i, playerClientSided in pairs(Players:GetPlayers()) do
		
		local charact = playerClientSided.Character
		
		local bilbrdGui = script:WaitForChild("UserIdGUI"):Clone()
		bilbrdGui.Parent = charact.PrimaryPart
		bilbrdGui.TextLabel.Text = playerClientSided.UserId
		
		playerClientSided.CharacterAdded:Connect(function(char)
			print("ADDED")
			local bilbordGui = script:WaitForChild("UserIdGUI"):Clone()
			print(bilbordGui.Parent)
			bilbordGui.Parent = char.PrimaryPart
			print(bilbordGui.Parent)
			bilbordGui.TextLabel.Text = playerClientSided.UserId
			print("b")
		end)
	end
end)

image
(1. a, 2. Reseted, 3. Added, 4. nil…)

It works for the first time but second no which is weird

1 Like

Couldn’t you just use the Server for this and make this a lot easier?

it has to be client-sided for my purpose, since i want certain players to see id’s

I would suggest creating the nametags on the server and then on your client script making it so the visibility of the nametag is handled there.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.