local Parts = workspace.Map.didParts:GetChildren()
local D = false
local Damge = 15
for _,Parts in Parts do
if Parts:IsA("Part") then
Parts.Touched:Connect(function(plr)
local LocalPlayer = game.Players:GetPlayerFromCharacter(plr.Parent)
local Humanoid = plr.Parent:FindFirstChild("Humanoid")
if D == false then
D = true
Humanoid.Health = Humanoid.Health - Damge
wait(1)
D = false
end
if Humanoid.Health == 0 then
LocalPlayer.Robry.Value = 0
end
end)
end
end
Title is misleading. Please check the error before naming your title. You’re shadowing Parts.
local Players = game:GetService("Players")
local Parts = workspace.Map.didParts
local debounce = false
local dmg = 15
for _, part in Parts:GetChildren() do
if not part:IsA("BasePart") then continue end
part.Touched:Connect(function(touchedPart)
if debounce then return end
local Player = Players:GetPlayerFromCharacter(touchedPart.Parent)
if not Player then return end
local Humanoid = touchedPart.Parent:FindFirstChild("Humanoid")
debounce = true
Humanoid.Health -= dmg
if Humanoid.Health <= 0 then
Player.Robry.Value = 0
debounce = false
return
end
task.delay(1, function()
debounce = false
end)
end)
end
local debounce = {} -- Different debounce for each player
local damage = 15
for _, part in workspace.Map.didParts:GetChildren() do
if part:IsA("BasePart") then
part.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local hum = player.Character.Humanoid
if debounce[player] then return end
debounce[player] = true
hum:TakeDamage(damage)
task.wait(1)
debounce[player] = nil -- Don't set this to false, set it to nil
if hum.Health == 0 then
player.Robry.Value = 0
end
end)
end
end
local PlayerService = game:GetService("Players")
local Map = workspace:WaitForChild("Map",300)
local KillParts = Map and Map:WaitForChild("didParts",30)
local State = true
local Damage = 15
local Cooldown = 1
------------------------------------------------------------------------
local function Touched(Part)
Part.Touched:Connect(function(Hit)
local Player = PlayerService:FindFirstChild(Hit.Parent.Name)
local Robry = Player and Player:FindFirstChild("Robry")
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Player and Humanoid and Robry and State then
State = false
Humanoid:TakeDamage(Damage)
if Humanoid.Health <= 0 then
Robry.Value = 0
end
task.wait(Cooldown)
State = true
end
end)
end
------------------------------------------------------------------------
for _, Part in pairs(KillParts:GetChildren())do
if Part:IsA("Part") then
Touched(Part)
end
end
Just to clarify, did you want accessories to trigger kill parts, or just the user’s limbs? Either way, the best way would be to hit the player a defined hitbox welded to their root part, and detect that instead.
Absolutely not
You can use this to detect accessories as well as body parts ^^
script.Parent.Touched:Connect(function(Hit)
local Character = Hit:FindFirstAncestorWhichIsA("Model")
print(Hit.Name, Hit.Parent.Name, Character.Name)
end)