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

How can i fix this welding script that don't work?

I made this script a while ago, and it's supposed to SIMPLY create a part and weld it to player's left hand. The thing is that i have no idea on how to fix the error and i already tried a lot of solutions that didn't work. Here's the script:

Script:

game.Players.PlayerAdded:Connect(function(player)

	local part = Instance.new("Part", workspace)
    local weld = Instance.new("Weld", part)
    weld.Part0 = part
    weld.Part1 = game.Workspace.player["LeftHand"]
    weld.C0 = CFrame.new(0, 0, 0) *CFrame.new(0, 0, 0)

end)

Error:

player is not a valid member of Workspace

I would be glad if anyone help, because i've been trying for a long time and i keep getting errors.

:(

PS: Everything except for that error works because i already tested with my own username.

2 answers

✓ Accepted answer

you could do

game.Players.PlayerAdded:Connect(function(player)

    local part = Instance.new("Part", workspace)
    local weld = Instance.new("Weld", part)
    weld.Part0 = part
    weld.Part1 = game.Workspace:WaitForChild(player.Name)["LeftHand"]
    weld.C0 = CFrame.new(0, 0, 0) *CFrame.new(0, 0, 0)

end)

wait for the player's character to be spawned then weld it

3 comments

0

it works for me

0

I'll check out

0

Worked. Thanks.

Player is considered to be the Player Object rather than the Player Model in Workspace. I recommend changing line 6 to player:WaitForChild("Character"):WaitForChild("Left Hand")

2 comments

0

Don't work.

0

it gives me a error: Infinite yield possible on 'Players.David0fficial_BR:WaitForChild("Character")'

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