What do you want to achieve? Keep it simple and clear!
How to apply touchingParts or newer method WorldRoot:GetPartsInPart to have one anchored part damage an anchored dummy.
What is the issue? Include screenshots / videos if possible!
A power/skill in game makes a part appear and cause damage to npcs. But since its anchored it doesnt damage anchored dummies. Since the touched.connect doesnt work when both parts are anchored. Atleast without using touchingParts correctly.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried many variations of the 2 scripts posted but just cant get it working right.
Help is greatly appreciated on the matter!
local hit = true
NewSpike.Touched:Connect(function(Hit)
if hit == false then return end
hit = false
local char = Plr.Character
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Name ~= char.Name then
Hit.Parent.Humanoid:TakeDamage(999)
wait(2)
hit = true
end
end)
local char = Plr.Character
NewSpike.Touched:Connect(function()
local touchingParts = NewSpike:GetTouchingParts() --gets a table of touching parts
for i, Hit in pairs(touchingParts) do -- loops through all the touching parts
if Hit.Parent:FindFirstChild("Humanoid") then
local ehum = Hit.Parent:FindFirstChild("Humanoid")
if not ehum.Parent:FindFirstChild("AlreadySpiked" .. char.Name) then
local HitTag = Instance.new("BoolValue", ehum.Parent)
HitTag.Name = "AlreadySpiked" .. char.Name
HitTag.Parent = ehum.Parent
game.Debris:AddItem(HitTag, 0.8)
ehum:TakeDamage(999)
end
end
end
end)
NewSpike.Touched:Connect(function()
local touchingParts = NewSpike:GetTouchingParts() --gets a table of touching parts
for i, Hit in pairs(touchingParts) do -- loops through all the touching parts
--if Hit.Parent:FindFirstChild("Humanoid") then
local enum = Hit.Parent:FindFirstChild("AlreadySpiked")
if enum == nil then
local HitTag = Instance.new("BoolValue")
HitTag.Name = "AlreadySpiked"
HitTag.Parent = enum
game.Debris:AddItem(HitTag, 0.8)
--here put you dummy humanoid
game.Workspace.MyDummy.Humanoid:TakeDamage(999)
end
--end
end
end)
Can you explain what you’re trying to do?
In my understanding, you want to damage a dummy if a player stands on a part, with a debounce of 0.8 seconds?
--put this script inside your part
local part = script.Parent
local dummies = {}
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent:FindFirstChild("HumanoidRootPart") ~= nil then
local was = false
for i,v in pairs(dummies) do
if v == hit.Parent.Humanoid then
was = true
end
end
if was == false then
hit.Parent.Humanoid:TakeDamage(30)
table.insert(dummies,hit.Parent.Humanoid)
end
end
end)
I’ll post a gif. Basically its a power and the part (spikes) currently only damage non anchored dummies/npcs and need it to damage anchored ones as well.
Yes, my user is knatedawg#1813 but we probably have to be in a mutual server. You can find mine in my bio or if you share your server I can join as well.