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

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

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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

Ad

Answer this question