Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Character is not a valid member of model?

Basically, whenever a Player joins the game or re-spawns I want this item on their player constantly.

Being effected on line 3 "Character is not a valid member of model"

game.Workspace.ChildAdded:connect(function(plr)
	local newPack = basicPack:Clone()
	newPack.Parent = plr.Character --this line here is being effected
	newPack.CFrame = plr.Character.UpperTorso.CFrame * CFrame.Angles(0, math.pi, 0)
	local weld = Instance.new("Weld")
	weld.Part0 = newPack
	weld.Part1 = plr.Character.UpperTorso
	weld.C0 = newPack.CFrame:inverse()
	weld.C1 = plr.Character.UpperTorso.CFrame:inverse()
	weld.Parent = newPack
end)

1 answer

✓ Accepted answer

It's because character is the model that spawns in workspace, players are in game.Players

However, there's a much easier way to do this

local players = game:GetService("Players")
players.PlayerAdded:Connect(function(pl)
	pl.CharacterAdded:Connect(function(character)
		print(character.Name.." respawned")
	end)
end)

1 comment

1

Appreciate it

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