Im trying to make a survival game, but the script is doing too much damage and firing when not clicking
Script doing more damage than usual, + damaging when not clicking
local Animator = workspace:FindFirstChild(script.Parent.Parent.Parent.Parent.Parent.Name):FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator")
local Cooldown = script.Parent.Parent.Cooldown
local Animation = script.Parent.Parent.Animation
script.Parent.MouseButton1Click:Connect(function()
if Animator then
if Cooldown.Value == 0 then
wait(0)
Cooldown.Value = 2
local anim = Animator:LoadAnimation(Animation)
anim:Play()
Animator.Parent.Parent:FindFirstChild("Hitboxes"):FindFirstChild("KickBox").Touched:Connect(function(otherPart: BasePart)
if script.Parent.Parent.Cooldown.Value == 0 then
if otherPart.Parent:FindFirstChildOfClass("Humanoid") then
otherPart.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(5)
end
end
end)
local anim = Animator:LoadAnimation(Animation)
anim:Play()
else
print("Failed2")
end
else
print("Failed")
end
end)```
local Animator = workspace:FindFirstChild(script.Parent.Parent.Parent.Parent.Parent.Name):FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator")
local Cooldown = script.Parent.Parent.Cooldown.Value::number
local Animation = script.Parent.Parent.Animation::Animation
local anim = Animator:LoadAnimation(Animation)
local db = false
Animator.Parent.Parent:FindFirstChild("Hitboxes"):FindFirstChild("KickBox").Touched:Connect(function(otherPart: BasePart)
if not db then return end
local hum:Humanoid? = otherPart.Parent:FindFirstChild("Humanoid")
if not hum then return end
hum:TakeDamage(5)
end)
script.Parent.MouseButton1Click:Connect(function():()
if db then return end
db = true
anim:Play()
task.wait(Cooldown)
db = false
end)
The thing you described is called solution farming, my friend.
What is the point of a solution without an actual explanation?
Also i did infact provide solution.
Besides, what is wrong with you disagreeing with straight-up facts?
That looks like a projection. Do you code that badly too?
wait(0.1)
local Animator = workspace:FindFirstChild(script.Parent.Parent.Parent.Parent.Parent.Name):FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator")
local Cooldown = script.Parent.Parent.Cooldown
local Animation = script.Parent.Parent.Animation
script.Parent.MouseButton1Click:Connect(function()
if Animator then
if Cooldown.Value == 0 then
wait(0)
Cooldown.Value = 2
local anim = Animator:LoadAnimation(Animation)
anim:Play()
local anim = Animator:LoadAnimation(Animation)
anim:Play()
Animator.Parent.Parent:FindFirstChild("KickboxScript").Enabled = true
wait(0.1)
Animator.Parent.Parent:FindFirstChild("KickboxScript").Enabled = false
else
print("Failed2")
end
else
print("Failed")
end
end)
touch = script.Parent:FindFirstChild("Hitboxes"):FindFirstChild("KickBox").Touched:Connect(function(otherPart: BasePart)
if otherPart.Parent:FindFirstChildOfClass("Humanoid") then
if otherPart.Parent ~= script.Parent.Parent.Parent then
otherPart.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(5)
touch:Disconnect()
script.Enabled = false
end
end
end)