Can someone tell me what’s wrong with this
I have been brain farting and forgot how to make a damage touched event right for some reason it does not do damage
I have made a ice spike that shoots from the ground and expands forward at an angle
HitBox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) and hit.Parent.Name ~= plr.Name then
if hit.Parent:FindFirstChild(“HitFolder”) and not hit.Parent:FindFirstChild(“HitFolder”):FindFirstChild(plr.Name) then
local x = Instance.new("IntValue", hit.Parent:FindFirstChild("HitFolder"))
x.Name = plr.Name
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
game.Debris:AddItem(hit.Parent:FindFirstChild("HitFolder"),4)
else
local folderX = Instance.new("Folder", hit.Parent)
folder.Name = "HitFolder"
local x = Instance.new("IntValue", hit.Parent:FindFirstChild("HitFolder"))
x.Name = plr.Name
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
game.Debris:AddItem(folderX, 4)
end
end
end)
local part = script.Parent
part.Touched:Connect(function(object))
local character = object.Parent
local humanoid = character.Humanoid
humanoid.Health = 0
This inside a script whose parent is a part will kill the player when the part is touched
local Spike = script.Parent
local BaseDamage = 25
local DB = false
Spike.Touched:Connect(function(Hit)
if not DB and Hit.Parent:FindFirstChild("Humanoid") then
DB = true
local Humanoid = Hit.Parent.Humanoid
Humanoid:TakeDamage(BaseDamage)
wait(1)
DB = false
end
end)
@FamorBlox There’s no end, and you can’t just add no sanity checks cause the script is already assuming that whenever the Touched event is fired, its assuming that there’s a Humanoid object already in there
you should define this before the if statement because you get it the humanoid twice
local Spike = script.Parent
local BaseDamage = 25
local DB = false
Spike.Touched:Connect(function(Hit)
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if not DB and Humanoid then
DB = true
Humanoid:TakeDamage(BaseDamage)
wait(1)
DB = false
end
end)
I should have been better explaining my bad. I forgot the whole damage script I had
this is what didn’t work, the damage script I posted in my edited script.
Ya my mistake, i forgot to end the function and the checks is definitly somethign that must be added every time but i was just showing the basic event.