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

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
1
Answered by 5 years ago

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

0
it works for me Questofmagicfarts 55 — 5y
0
I'll check out User#27525 1 — 5y
0
Worked. Thanks. User#27525 1 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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")

0
Don't work. User#27525 1 — 5y
0
it gives me a error: Infinite yield possible on 'Players.David0fficial_BR:WaitForChild("Character")' User#27525 1 — 5y

Answer this question