Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get one anchored part damage another anchored part/dummy?

Asked by 2 years ago
Edited 2 years ago

Since touched.connect doesnt work when 2 anchored parts touch (without using touchingParts). I can't find a way to make my scripts work. They work fine and damage unanchored dummies/npcs but not anchored ones.

So I want to find a way to apply GetTouchingParts or newer method GetPartsInPart as seen in following link: https://devforum.roblox.com/t/introducing-overlapparams-new-spatial-query-api/1435720

Help is greatly appreciated!

Both of the following codes work on unanchored parts. Code option 1:

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("AlreadyDekuPunched" .. char.Name) then

                            local HitTag = Instance.new("BoolValue", ehum.Parent)
                            HitTag.Name = "AlreadyDekuPunched" .. char.Name
                            HitTag.Parent = ehum.Parent
                            game.Debris:AddItem(HitTag, 0.8)

                            ehum:TakeDamage(999)
                        end
                    end
                    end
                        end)

Code option 2:

local part = script.Parent
local dummies = {}
part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent:FindFirstChild("HumanoidRootPart") ~= nil then
        print(2)
        local was = false
        for i,v in pairs(dummies) do
            if v == hit.Parent.Humanoid then
                was = true
            end
        end
        if was == false then
            print(3)
            hit.Parent.Humanoid:TakeDamage(30)
            table.insert(dummies,hit.Parent.Humanoid)
        end
    end
end)
0
The Touched event cannot detects anchored parts totosimamora608 61 — 2y
0
Correct, so I'm trying to find a way to use GetTouchingParts or GetPartsInPart. KnateDawg 0 — 2y

Answer this question