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

Why is this welding script not working properly after a player resets?

I have a welding script inside multiple tools in my game. Here's the script:

local t = script.Parent
local h = t.Handle
local e = {}

for i,v in pairs(t:GetChildren()) do
	if v:IsA("BasePart") then
		local w = Instance.new("Weld", game.JointsService)
		w.C1 = v.CFrame:toObjectSpace(h.CFrame)
		w.Part0 = h
		w.Part1 = v
		table.insert(e, w:Clone())
	end
end

script.Parent.Equipped:connect(function()
	for i,v in pairs(e) do
		v:Clone().Parent = game.JointsService
	end
end)

The problem is that, after a player resets and the tools are immediately given to the player, the script doesn't function properly. Here's a video example in my game:

https://www.youtube.com/watch?v=qEmX_D0Wr34

So, can anyone explain why it's not functioning right?

1 answer

Make sure the weapons are in the server storage, I believe the script should look something like this:

local tool = game.ServerStorage.GearName

function onPlayerSpawned(player) then tool:Clone().Parent = player.Backpack end end

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