GIF: https://gyazo.com/aec7f0f8ec266b213ff10f3dd463dde8
Script:
----- Variables
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Tool = script.Parent
local animation = script:WaitForChild("SwingAnim")
local CanSwing = true
local Swinging = false
local Settings = {
SwingTime = 0.5,
Damage = 15,
}
----- Functions
Tool.Activated:Connect(function()
if CanSwing then
Swinging = true
print("Activated")
local animtrack = Character:WaitForChild("Humanoid"):LoadAnimation(animation)
animtrack:Play()
CanSwing = false
Tool.Handle.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
Tool:WaitForChild("R"):FireServer("Hit",hit.Parent,Settings.Damage)
end
end)
wait(Settings.SwingTime)
CanSwing = true
Swinging = false
end
end)

1 comment
It works perfectly in the editor and nothing is wrong with it idk why it isn't working