I use a particular script for damage/kill parts, the script is you simply touch part and it takes health. I used this script for years but in a new game that I’ve recently published, it either works only first few minutes when the server is new, or does not work at all. Moreover, in studio it works absolutely fine.
The script in question:
debounce = false
script.Parent.Touched:Connect(function(hit)
if not debounce then
debounce = true
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
end
wait(0.5)
debounce = false
end
end)
I assume that maybe input gateway script by Maximum_ADHD causes the problem? Or collision with some other scripts? Any help or advice is much appreciated
local debounce = false
script.Parent.Touched:Connect(function(hit)
if debounce then return end
local character = hit.Parent
if not character then return end
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
debounce = true
humanoid:TakeDamage(10)
task.delay(0.5, function()
debounce = false
end)
end
end)