Hello i'm trying to make a attack script. The script works in studio but in the game not work :/ here it's the script:
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character
local debounceQ = true
local debounceTime = 0.5
local debounceE = true
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
if debounceQ == true then
if Player.CanAttack.Value == true then
if Character ~= nil then
if Character:FindFirstChild("Humanoid") then
debounceQ = false
local Humanoid = Character.Humanoid
local Anim1 = Humanoid:LoadAnimation(script.AttackQ)
local Anim2 = Humanoid:LoadAnimation(script.AttackE)
Anim1:Play()
Player.CanDamageQ.Value = true
wait(debounceTime)
Player.CanDamageQ.Value = false
wait(0.4)
debounceQ = true
end
end
end
end
end
end)
Character:WaitForChild("Left Arm").Touched:connect(function(hit)
if Player.CanDamageQ.Value == true then
if hit.Parent:FindFirstChild("Humanoid") then
local hum = hit.Parent.Humanoid
hum:TakeDamage(5)
end
end
end)
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if debounceE == true then
if Player.CanAttack.Value == true then
if Character ~= nil then
if Character:FindFirstChild("Humanoid") then
debounceE = false
local Humanoid = Character.Humanoid
local Anim1 = Humanoid:LoadAnimation(script.AttackQ)
local Anim2 = Humanoid:LoadAnimation(script.AttackE)
Anim2:Play()
Player.CanDamageE.Value = true
wait(debounceTime)
Player.CanDamageE.Value = false
wait(0.4)
debounceE = true
end
end
end
end
end
end)
Character:WaitForChild("Right Arm").Touched:connect(function(hit)
if Player.CanDamageE.Value == true then
if hit.Parent:FindFirstChild("Humanoid") then
local hum = hit.Parent.Humanoid
hum:TakeDamage(5)
end
end
end)
pls help me!

2 comments
USE WAITFORCHILD SO IT CAN LOAD
"The script works in studio but in the game not work" is very broad.