For some unknown reason, my weld doesn’t work sometimes, every other equip and unequip works.
I think it’s because the values keep changing so fast. I really don’t know how to fix it.
local RS = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local char = plr.Character
local animator = char.Humanoid.Animator
local weapon = char:WaitForChild("Weapon")
local equipAnims = weapon.equipAnims
local events = RS.Events
local keybindsFolder = script.Parent.Keybinds
local equipAnim = animator:LoadAnimation(equipAnims.equip)
local unequipAnim = animator:LoadAnimation(equipAnims.unequip)
local equip = false
local equipEvent = events.equipEvent
local equipAnim = animator:LoadAnimation(equipAnims.equip)
local unequipAnim = animator:LoadAnimation(equipAnims.equip)
uis.InputBegan:Connect(function(input,isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode[keybindsFolder.equipWeapon.Value] then
if equipAnim.IsPlaying or unequipAnim.IsPlaying then return end
if equip == false then
equip = true
equipAnim:GetMarkerReachedSignal("weld"):Connect(function()
equipEvent:FireServer()
end)
equipAnim:Play()
else
equip = false
unequipAnim:GetMarkerReachedSignal("weld"):Connect(function()
equipEvent:FireServer()
end)
unequipAnim:Play()
end
end
end)
local Weld = {}
local RS = game:GetService("ReplicatedStorage")
local Weapons = RS.Weapons
local weaponWelds = script.welds
local Events = RS.Events
local equipEvent = Events:WaitForChild("equipEvent")
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local charValues = char:WaitForChild("valuesFolder")
local torso = char.Torso
local weaponModel = Weapons[charValues.Weapon.Value]:Clone()
weaponModel.Parent = char
weaponModel.Name = "Weapon"
local weldValues = weaponWelds[charValues.Weapon.Value]
local weld = Instance.new("Motor6D")
weld.Parent = char
weld.Name = "weaponWeld"
weld.Part0 = torso
weld.Part1 = weaponModel
weld.C1 = weldValues.weaponRest.C1
end)
end)
function Weld.weldEquip(char,tool)
local charValues = char:WaitForChild("valuesFolder")
local weld = char:WaitForChild("weaponWeld")
local weldValues = weaponWelds[charValues.Weapon.Value]
local torso = char.Torso
local rightArm = char["Right Arm"]
if charValues.Equipped.Value == false then
charValues.Equipped.Value = true
weld.Part0 = rightArm
weld.C1 = weldValues.weaponHold.C1
weld.CurrentAngle = 0
elseif charValues.Equipped.Value == true then
charValues.Equipped.Value = false
weld.Part0 =torso
weld.C1 = weldValues.weaponRest.C1
weld.CurrentAngle = 0
end
end
equipEvent.OnServerEvent:Connect(function(plr,tool)
Weld.weldEquip(plr.Character,tool)
end)
return Weld