Title says everything.
Also here's the code.
local Tool = script.Parent
local clickEvent = Tool.ClickEvent
local SpecialAttackEvent = Tool.SpecialAttackEvent
local clickEventConnection
local Sharp = script.Parent.Sharp
local Damage = Tool.Damage.Value
local SpecialDamage = Tool.SpecialDamage.Value
local enableDamage = true
local function onAttack(player)
-- TODO: Does a damage to the player target.
local Character = player.Character
script.Parent.Sharp.Touched:connect(function(hit)
if enableDamage then
if hit.Parent:findFirstChild("Humanoid") ~=nil then
print("Normal ATTACK!")
hit.Parent:findFirstChild("Humanoid").Health = hit.Parent:findFirstChild("Humanoid").Health - Damage;
enableDamage = false
end
end
end)
end
local function onEquip()
clickEventConnection = clickEvent.OnServerEvent:connect(onAttack)
end
local function onUnequip()
clickEventConnection:disconnect()
end
Tool.Equipped:connect(onEquip)
Tool.Unequipped:connect(onUnequip)
LocalScript
local Tool = script.Parent
local player = game.Players.LocalPlayer
local Character = player.Character
local mouse = player:GetMouse()
local clickEvent = Tool.ClickEvent
local SpecialAttackEvent = Tool.SpecialAttackEvent
local UserInputService = game:GetService("UserInputService")
local Damage = Tool.Damage.Value
local SpecialDamage = Tool.SpecialDamage.Value
local done = true
local enableDamage = false
local function onActivate()
local clickLocation = mouse.Hit
clickEvent:FireServer(clickLocation)
end
local function onAnimate()
if not done then return end
done = false
local a = Character.Torso["Right Shoulder"]
local i = 4.7
repeat
wait(0.005)
a.C0 = CFrame.new(1,0.5,-i/20) * CFrame.fromEulerAnglesXYZ(0,-i,i/math.pi)
i = i + 0.1
until i >= 5.9
repeat
wait(0.005)
a.C0 = CFrame.new(1,0.5,0) * CFrame.fromEulerAnglesXYZ(i - 20, -i, -i + 0.5)
i = i - 0.1
until i <= 4.5
wait()
a.C0 = CFrame.new(1,0.5,0) * CFrame.fromEulerAnglesXYZ(0,-4.7,0)
done = true
end
local function onSpecialAttack(inputObject, gameProcessedEvent)
-- TODO: Add a special attack activated by pressing Q
if inputObject.KeyCode == Enum.KeyCode.Q then
onAnimate()
script.Parent.Sharp.Touched:connect(function(hit)
if enableDamage then
if hit.Parent:findFirstChild("Humanoid") ~=nil then
enableDamage = true
print("Special ATTACK!")
hit.Parent:findFirstChild("Humanoid").Health = hit.Parent:findFirstChild("Humanoid").Health - SpecialDamage;
enableDamage = false
if Tool.Deactivated then
enableDamage = false
else
enableDamage = true
end
end
end
end)
end
end
Tool.Activated:connect(onActivate)
UserInputService.InputBegan:connect(onSpecialAttack)
