Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how would I use a touched event to figure out if 2 objects hit?

Just like how in games two swords hitting fire a sword hit sound once. Instead of twice whereas the touched event is handled by the clients. I've tried something where it gathers pairs of hits in a table but it doesn't seem efficient. I been at this for weeks and would really appreciate an answer.

3 comments

0

Can you post your current attempt to see what you've been working with?

0

Please provide an attempt or explain why your attempt wasn't "efficient"

0

You should know by now that we cannot help if you do not include your code you are using.

1 answer

Use :GetTouchingParts

local obj = workspace.Part
for _, v in pairs(obj:GetTouchingParts()) do
    if v.Name == "OtherPart" then -- change to part to get touched
	    -- run code
	    -- when the part is touched by another part, do a specific function here
    end
end

1 comment

0

ugh I hate stack edit thingi, so ill just explain here, :GetTouchingParts() gets all the parts touching obj, all the items are given in a table which then you will retrieve.

This discussion is preserved as it was. New answers, comments, and votes are closed.