Hello, people of the devfourm, I have been trying to fix this issue for a few days and was wondering if you guys could help me. I am developing a lightsaber tool and animations we made are not playing on the lightsaber even when using motor6d’s
Issue in Visual format
Please note this is all the code however the motor6d does not start until the very bottm (This is a server script)
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local AnimationRemote = game.ReplicatedStorage.AnimationRemote
local player = tool.Parent.Parent
local character = player.Character
local CanDamage = false
local debounce = true
local ComboCount = 1
local LastSwing = tick()
script.Parent.Union.Touched:Connect(function(Hit)
local Humanoid = Hit.Parent:FindFirstChildOfClass('Humanoid')
if Humanoid and CanDamage and not Hit.Parent:IsDescendantOf(tool.Parent) then
Humanoid:TakeDamage(10)
game.ReplicatedStorage.HitRemoteSound:FireAllClients()
CanDamage = false
wait(0.5)
CanDamage = true
end
end)
tool.Activated:Connect(function()
if debounce then
debounce = false
CanDamage = true
-- Combo System
local ExtraDelay = 0
if tick() - LastSwing > 0.5 and ComboCount >= 5 then
-- Reset Combo
ComboCount = 1
ExtraDelay = 0.5
else
-- Increase Combo
ComboCount = ComboCount + 1
end
AnimationRemote:FireAllClients(ComboCount)
LastSwing = tick()
wait(0.4)
CanDamage = false
debounce = true
end
end)
tool.Equipped:Connect(function()
local Motor = Instance.new("Motor6D", character["Right Arm"])
Motor.Name = "Moto6f"
Motor.Part0 = character["Right Arm"]
Motor.Part1 = tool.Handle
end)
tool.Unequipped:Connect(function()
local Motor = character["Right Arm"]:FindFirstChild("Moto6f")
if Motor then
Motor:Destroy()
end
end)