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

Welded Tool Falls Apart When Re-equipped?

Asked by 9 years ago

How would I get this tool to stay together? I pick up the tool (which has 3 parts, welded together) and then when I unequip and then equip it again it falls apart and only the handle remains? Is it something wrong with the script?

Weld Script -

local base = script.Parent  -- Tool handle, the script is inside the tool handle
local part = script.Parent.Wrapper  -- Part of tool, child of the handle

local weld = Instance.new("Weld", game.JointsService)
weld.Part0 = base
weld.Part1 = part
weld.C0 = CFrame.new(0,0,0) -- All the parts are located within 0.3 studs of  each other so this would work, right? It works without me unequipping.. 
weld.C1 = CFrame.new(0,0,0)
local base = script.Parent.TeaLiquid  -- Another part of tool, child of the handle
local part = script.Parent.Wrapper

local weld = Instance.new("Weld", game.JointsService)
weld.Part0 = base
weld.Part1 = part
weld.C0 = CFrame.new(0,0,0)
weld.C1 = CFrame.new(0,0,0)

http://imgur.com/fEAIdx4

0
It does work, you're just not using it correctly, the thing is, it isn't the whole script, you weld into the handle, then you use that script, EzraNehemiah_TF2 3552 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

You need to create the welds whenever you equip the tool. Let me know if this does not work, please specify more clearly if this was not the correct answer, tell us where in the script the welds are made!

--YOU PROBABLY WANT TO USE A LOCAL SCRIPT!!!

Tool = script.Parent -- Look at the script, and trace how many parents until you get to the tool object, be sure to change this value accordingly

Tool.Equipped:connect(function()
--put welding stuff here
end)

-- THIS WORKS AS WELL

function OnEquip()
--weld stuff here
end

Tool.Equipped:connect(OnEquip)
0
Thank you, I will try it out! Brisingr360 45 — 9y
0
No, I am afraid the tool falls apart still. Is the 'Tool' variable supposed to be the actual tool itself or the handle of the tool? Brisingr360 45 — 9y
0
the tool itself, where is the script in the hierarchy of the tool? and are you using a local script? dragonkeeper467 453 — 9y
0
I am not using a local script. But I tried using 'Tool = script.Parent.Parent' (the tool) and 'Tool=script.Parent' (the handle) Brisingr360 45 — 9y
View all comments (4 more)
0
You need to use a local script, first of all, then figure write in the correct hierarchy for the tool from the script dragonkeeper467 453 — 9y
0
If I use a local script the tool doesn't weld in the first place. Brisingr360 45 — 9y
0
it should be welding if you use a local script, I'm making a gun script as well with a local script and it works perfectly fine dragonkeeper467 453 — 9y
0
Can you please include the entire hierarchy under the tool! dragonkeeper467 453 — 9y
Ad
Log in to vote
-1
Answered by 9 years ago

This is how you would do it: Add the welds into the handle, use the Equipped event and MakeJoints.

script.Parent.Equipped:connect(function()
    script.Parent.Handle:MakeJoints()
end)

Hope it helps!

0
Thanks so much! I'll try it! Brisingr360 45 — 9y
0
I'm afraid it did not work. e.e Brisingr360 45 — 9y

Answer this question