for count = 1, 25, 1 do
script.Parent.indicate.Transparency = script.Parent.indicate.Transparency - 0.04
if count == 25 then
local target = script.Parent.damage:GetTouchingParts()
print(target)
print("boom")
script.Parent:Destroy()
else
wait(0.04)
end
end
even I touched damage part it still says like this also target[1] is still nil
(here is output)
{}
boom
So you’re damaging the parent of the script, then finding the touching parts of the damage??
This code doesn’t really make sense. If you want to put all the touching parts into a list, just type:
local targets = script.Parent:GetTouchingParts()
As for the damaging, you can use a for loop to damage all touching parts, like this:
for i,v in pairs(targets) do
if v.Parent:FindFirstChild("Humanoid") ~= nil then
v.Parent:TakeDamage(5) -- Change depending on how much you want to damage the players touching the part.
end
end
Hopefully this is what you need, if it’s something different, just let me know.
The output is, “{}” because the part isn’t touching anything.
I don’t really understand what you want either.
If you want a damage part, you can use this.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:BreakJoints()
end
end)
Edit: I think I know what you mean.
script.Parent.Touched:Connect(function(hit)
print("hello")
if hit.Parent:FindFirstChild("Humanoid") then
local Targets = script.Parent:GetTouchingParts()
for i, v in pairs(Targets) do
print(Targets)
end
hit.Parent:BreakJoints()
end
end)