I tried inserting a String Value (renamed Hotkey) to see if I can make a Hotkey to activate my script but its not working!
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://476354090"
local LoadedAnimation = Humanoid:LoadAnimation(Animation) -- Load the animation only once
local UserInputService = game:GetService("UserInputService")
Mouse.KeyDown is depreciated
local CanDamage = false
LoadedAnimation.Stopped:connect(function()
CanDamage = false
end)
UserInputService.InputBegan:connect(function(Input, GME)
if not GME then
if Input.KeyCode == Enum.KeyCode[script.Hotkey.Value] then
LoadedAnimation:Play()
CanDamage = true
end
end
end)
local Cooldown = false
script.Parent.Touched:connect(function(Part)
local Human = Part.Parent:findFirstChild("Humanoid")
if Human and Human.Parent.Name ~= Character.Name and CanDamage and not Cooldown then
Cooldown = true
Human:TakeDamage(20)
wait(1.7)
Cooldown = false
end
end)
