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

Why is the script killing me when I try to weld it up?


local lplayer = game.Players.LocalPlayer

local HumT = lplayer.Character.Torso

local RepStore = game:GetService("ReplicatedStorage")


local Players = game:GetService("Players")

function OnPlayerAdded(plr)
	print("Hello!")
	
local part2 = RepStore.Blocky:Clone()



local weld = Instance.new("Weld")
weld.Part0 = part2
HumT.Parent = lplayer
part2.Parent = HumT
weld.Part1 = HumT

weld.C0 = CFrame.new(0,0,0)
weld.C1 = CFrame.new(0,0,0)
	
	
end
	

for _,v in pairs(Players:GetPlayers()) do
	OnPlayerAdded(plr)
end

It kills me when I try to weld a part to the Character's Torso. Each time I respawn.

1 comment

0

I have on ReplicatedStorage a 2x2x2 part named "Blocky" as you might see. I'm trying to clone it and weld it to the Character's Torso. But for some strange reason when I press "play" the character spawns and it instantly dies, and it doesn't stop loop killing me, any help on this ?

1 answer

✓ Accepted answer

You set the player's torso to the player, which is why it kept killing them. The torso doesn't need to be parented. You also forgot to set the parent of the weld.

And I'm not sure why it even worked, because in lines 31-33, you used 'plr' which wasn't defined. If you're trying to loop through the players and do it for all of them, then substitute plr with v, as I did. You should also connect the function to the actual player added event, which I assume is what you wanted to do from 'OnPlayerAdded', as right now it'll only run once.

local lplayer = game.Players.LocalPlayer

local HumT = lplayer.Character.Torso

local RepStore = game:GetService("ReplicatedStorage")


local Players = game:GetService("Players")

function OnPlayerAdded(plr)
    print("Hello!")

local part2 = RepStore.Blocky:Clone()
part2.Parent = game.Workspace



local weld = Instance.new("Weld")
weld.Parent = part2
weld.Part0 = part2
part2.Parent = HumT
weld.Part1 = HumT


weld.C0 = CFrame.new(0,0,0)
weld.C1 = CFrame.new(0,0,0)


end


for _,v in pairs(Players:GetPlayers()) do
    OnPlayerAdded(v)
end

game.Players.PlayerAdded:connect(OnPlayerAdded) -- Add this if you want it to run the function when a player is added.

4 comments

0

It shows up with this error: "Workspace.Blocky to Workspace.Blocky.Torso would result in circular reference "

0

I made about a billion mistakes, pretty sure I just fixed it again. My fault!

0

Thanks Pyrondon. Very helpfull!

0

No problem.

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