I’m having an issue with animation specifically the weapon animation.
I create the weld (Motor6D) in the server and change it values there, while the client plays the animation and fire a remote event to sync the weld values changing. For some unknown reason it won’t let the weapon go to it’s coordinate positions.
-- Module
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,equip)
local torso = char.Torso
local rightArm = char["Right Arm"]
local charValues = char:WaitForChild("valuesFolder")
local weapon = char:WaitForChild("Weapon")
local weld = char:WaitForChild("weaponWeld")
local weldValues = weaponWelds[charValues.Weapon.Value]
if equip then
weld.Part0 = rightArm
weld.C1 = weldValues.weaponHold.C1
weld.CurrentAngle = 0
else
weld.Part0 = torso
weld.C1 = weldValues.weaponRest.C1
weld.CurrentAngle = 0
end
equipEvent:FireServer(weld)
end
equipEvent.OnServerEvent:Connect(function(plr,equip)
Weld.weldEquip(plr.Character,equip)
end)
return Weld
-- Local
local uis = game:GetService("UserInputService")
local rs = game:GetService("ReplicatedStorage")
local plrService = game:GetService("Players")
local plr = plrService.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 holdAnim = animator:LoadAnimation(equipAnims.hold)
local unequipAnim = animator:LoadAnimation(equipAnims.unequip)
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
equipAnim:GetMarkerReachedSignal("weld"):Connect(function()
equipEvent:FireServer(equip)
end)
if equipAnim.Ended then
holdAnim:Play()
end
equipAnim:Play()
equip = true
else
holdAnim:Stop()
unequipAnim:GetMarkerReachedSignal("weld"):Connect(function()
equipEvent:FireServer(equip)
end)
unequipAnim:Play()
equip = false
end
end
end)