I added a script that when you press the 1 key a remotevent fires a server script and when the server script is fired whoever is inside the hitbox gets hurt and then waits a cooldown, but for some reason the hitbox keeps turning on even when I dont press one, I added a print and it turns out the script just keeps running every 7 seconds
this is the server script:
local humanoid = script.Parent.Parent:WaitForChild("Humanoid")
local biteAnim = script.Parent.Parent["whale anim"].Bite
local debounce = true
local Anim = humanoid:LoadAnimation(biteAnim)
local time = Anim.length
local remote11 = game.ReplicatedStorage.RemoteEvent11
remote11.OnServerEvent:Connect(function()
game:GetService("RunService").Heartbeat:Connect(function()
for _, v in pairs(workspace:GetPartsInPart(script.Parent)) do
if v.Parent:FindFirstChild("Humanoid") then
if debounce == true then
debounce = false
script.Parent.CanTouch = true
print("it worked")
v.Parent.Humanoid:TakeDamage(100)
wait(time)
task.wait(7)
debounce = true
end
end
end
end)
end)
** You are now Level 1! **