Why isn't Alive being cloned to the player's character?

I’m trying to clone “Alive” to the player’s character. Right now, it doesn’t do that. Alive is a sibling of the script, and the parent BoolValue’s value is true.

local plrs = game:GetService('Players')

plrs.PlayerAdded:Connect(function(plr)
	if script.Parent.Value == true then
		wait(plr.Character)
		script.Parent.Alive:Clone().Parent = plr.Character
	else
		plr:Kick('The round has already started, joining is now disabled.')
	end
end)

didn’t wait for the players character to load, since the player loads before the character.
^ you did wait, but i dont think it actually waited

local plrs = game:GetService('Players')

plrs.PlayerAdded:Connect(function(plr)
       plr.CharacterAdded:Connect(function(char)
	    if script.Parent.Value == true then
		  script.Parent.Alive:Clone().Parent = char
	    else
		  plr:Kick('The round has already started, joining is now disabled.')
	    end
      end)
end)

^bad formatting due to writing in on devfourms sorry, working on it

1 Like

wait(plr.Character) isn’t correct. You can do the following:

local plrs = game:GetService('Players')

plrs.PlayerAdded:Connect(function(plr)
	local char = plr.Character or plr.CharacterAdded:Wait()
	if script.Parent.Value == true then
		script.Parent.Alive:Clone().Parent = char
	else
		plr:Kick('The round has already started, joining is now disabled.')
	end
end)
1 Like

this would also work :slight_smile:

(this one just checks if the character already exsists, and if it doesnt it waits for it to)

1 Like

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