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

Character is not a valid member of model?

Asked by 6 years ago

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

Log in to vote
1
Answered by
Vulkarin 581 Moderation Voter
6 years ago
Edited 6 years ago

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
Appreciate it YouSNICKER 131 — 6y
Ad

Answer this question