Basically I have these arm welds whenever I'm holding a tool, and from there, I do an animation that is played when I press T on the keyboard, and after I unequip it, my arms are still welded. Please help!
Weld Script:
Tool = script.Parent;
local arms = nil
local torso = nil
local welds = {}
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
function Equip(mouse) --When Tool is Equipped
wait(0.01)
arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")}
torso = Tool.Parent:FindFirstChild("Torso")
if arms ~= nil and torso ~= nil then
local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
if sh ~= nil then
local yes = true
if yes then
yes = false
sh[1].Part1 = nil
sh[2].Part1 = nil
local weld1 = Instance.new("Weld")
weld1.Part0 = torso
weld1.Parent = torso
weld1.Part1 = arms[1]
weld1.C1 = CFrame.new(1.4, .5, 0.5) * CFrame.fromEulerAnglesXYZ(math.rad(-75), -0, math.rad(5))
welds[1] = weld1
local weld2 = Instance.new("Weld")
weld2.Part0 = torso
weld2.Parent = torso
weld2.Part1 = arms[2]
weld2.C1 = CFrame.new(-1.4, .5, .5) * CFrame.fromEulerAnglesXYZ(math.rad(-75), 0, math.rad(-5), 0)
welds[2] = weld2
end
else
print("sh")
end
else
print("arms")
end
end
function Unequip(mouse) --When Tool is Unequipped
if arms ~= nil and torso ~= nil then
local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
if sh ~= nil then
local yes = true
if yes then
yes = false
sh[1].Part1 = arms[1]
sh[2].Part1 = arms[2]
welds[1].Parent = nil
welds[2].Parent = nil
end
else
print("sh")
end
else
print("arms")
end
end
Weld Script #2:
local UIS = game:GetService("UserInputService")
local debounce = false
UIS.InputBegan:connect(function(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.T then
if debounce == false then
if script.Parent.AnimDebounce.Value == true and script.Parent.Done.Value == true then
debounce = true
script.Disabled = true
script.Parent.Done.Value = false
Unequip()
script.Parent.rMovement.Disabled = true
script.Parent.lMovement.Disabled = true
wait()
Tool.GripPos = Vector3.new(0, 0, 0)
wait()
Tool.GripPos = Vector3.new(0.5, 0, -0.3)
wait(2.5)
script.Parent.rMovement.Disabled = false
script.Parent.lMovement.Disabled = false
Equip()
wait()
script.Parent.Done.Value = true
script.Disabled = false
debounce = false
end
end
end
end
end
end)
Animation Script: (Separate from the previous two scripts [The first two scripts are in the same script, just felt it would be better to separate them. This script is inside a different local script.]
local function onInputBegan(input,gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.T then
script.Disabled=true
wait() Tool.GripPos=Vector3.new(0.5,2,-0.3)
wait()
script.Parent.AnimDebounce.Value = false
Unequip()
wait()
dunkanim:Play()
script.Parent.Weld.Disabled = true
wait()
local Force=Tool.BodyForce:Clone()
if Tool.Parent:findFirstChild("Humanoid"and"Torso") then
script.Parent.StealBall.Disabled = false
Force.Parent=Tool.Parent.Torso
for i,v in pairs(Tool.Parent:GetChildren())do
if v:IsA("Accessory") then
Force.force=Force.force+Vector3.new(0,50*v.Handle.Size.Y,0)
end
end
wait(0.2)
if Tool.Parent:findFirstChild("Humanoid") then
Tool.Parent.Humanoid.Jump=true
end
end
end
wait(2.3)
script.Parent.AnimDebounce.Value = true
wait()
script.Disabled=false
script.Parent.Weld.Disabled = false
end
end
end
UIS.InputBegan:Connect(onInputBegan)
Video:
As you can see at the very end, my arms are still positioned towards when I do not have the tool. How would I fix this?
Thanks,
LukeGabrieI aka EnergyBrickz
