I have a part that has CanCollide == false
and Anchored == true
. I want it so that when a player is inside the part(in the area of effect), they will take damage every 1 second or so. I've tried multiple ways of going about this but they seem to never work. Is there a special way of doing this, can anyone help me out? Also, this has to do damage to multiple players over time not just one.
If you already have a working script, you're going to want to create layers so that when the player moves through it they take damage, or a loop that damages any players within it for a certain amount of time. the loop, based on your question, should be wait(1)
.
I made a script to put in the part, it has issues with it and doesn't work much but here it is.
local Settings = { ['TimeWait'] = .2, -- How long per run ['Damage'] = 5, -- Damage per Run } local using = false script.Parent.Touched:Connect(function(part) -- Part Touched if game:GetService("Players"):GetPlayerFromCharacter(part.Parent) then -- Checks if the part is a player if not using then if part.Name == "Left Leg" or part.Name == "LeftFoot" or part.Name == "HumanoidRootPart" then using = true print("Using") local humanoid = part.Parent:WaitForChild("Humanoid") while using do humanoid.Health = humanoid.Health - tonumber(Settings.Damage) wait(tonumber(Settings.Damage)) end end end end end) script.Parent.TouchEnded:Connect(function(part) if game:GetService("Players"):GetPlayerFromCharacter(part.Parent) then -- Checks if the part is a player if part.Name == "Left Leg" or part.Name == "LeftFoot" or part.Name == "HumanoidRootPart" then if using then using = false print("Not Using") end end end end)