Hey, I’ve been confused for some time and I am really wondering why the debounce doesn’t work…
Here is the server script:
local Services = {
Players = game:GetService("Players");
ServerStorage = game:GetService("ServerStorage");
}
local PartsFolder = workspace:WaitForChild("Parts")
local ServerLibs = Services.ServerStorage:WaitForChild("Libs")
local Modules = {
PartHandler = require(ServerLibs:WaitForChild("PartHandler"));
}
Services.Players.PlayerAdded:Connect(function(player)
for index, value in pairs(PartsFolder:GetDescendants()) do
Modules.PartHandler.new(player, value)
end
end)
Here is the serverstorage module:
local Services = {
Players = game:GetService("Players");
ReplicatedStorage = game:GetService("ReplicatedStorage");
}
local PartHandler = {}
PartHandler.new = function(player, part)
if part:IsA("Part") or part:IsA("MeshPart") then
local Debounce = {}
part.Touched:Connect(function(hit)
if part.Name == "DamagePart" then
local Character = hit.Parent
local Humanoid = Character:FindFirstChild("Humanoid") or nil
if Debounce[Character] then
return
end
if Humanoid then
Debounce[Character] = true
Humanoid:TakeDamage(part:GetAttribute("Damage"))
end
end
end)
part.TouchEnded:Connect(function(hit)
local Character = hit.Parent
Debounce[Character] = false
end)
end
end
return PartHandler
I have been searching through the devForum and didn’t find a solution.
Any help is appreciated.