Basicly I tried doing when the player leaves the part then the damage stops. But it stacks because of touched is ran per part. If I tried putting it as an another function it would just damage 1 player. What should I do 
--// Local Variables
local part = script.Parent
local kill = false
local killing = false
--// Set-Up
part.Touched:Connect(function(hit)
if hit:IsDescendantOf(part) then return end
if killing == false then
killing = true
local plr
local hum
if not plr and not hum then
if kill == false then
if hit.Parent:FindFirstChildOfClass("Humanoid") then
plr = hit.Parent
hum = hit.Parent:FindFirstChildOfClass("Humanoid")
elseif hit.Parent:IsA("Accessory") then
plr = hit.Parent.Parent
hum = hit.Parent.Parent:FindFirstChildOfClass("Humanoid")
end
repeat
hum:TakeDamage(8.5)
wait(0.25)
until killing == false or hum.Health == 0
end
end
end
end)
part.TouchEnded:Connect(function(hit)
if killing == true then
killing = false
end
end)
I don’t really understand what you are trying to do here, do you just want the player to get damaged when they touch the part?
Maybe you should try adding something into player’s character to indicate that if they’re touching the part or not.
I tried making a simple tag system or something along the line like that yea.
-- simple tag system
local part = script.Parent
local kill = false
local killing = false
--// Set-Up
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
local character = hit.Parent
local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if not character:FindFirstChild("IsBeingDamage") then
local tag = Instance.new("Model")
tag.Name = "IsBeingDamage"
tag.Parent = character
while wait(1) and tag ~= nil and tag:IsDescendantOf(character) do
humanoid:TakeDamage(5)
end
end
end
end)
part.TouchEnded:Connect(function(hit)
if hit.Parent:FindFirstChild("IsBeingDamage") then
hit.Parent.IsBeingDamage:Destroy()
end
end)
Perhaps you want to apply a regular loop that ticks the damage on the player. Instead of using TouchEnded, rely on the GetTouchingParts:
so far from what I see this might be possible. Will try it out.
Okey did some configurations and it worked! Tysm
1 Like