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

Help with Contact with non-CanCollide item cloned from ReplicatedStorage to Workspace?

I have it where whenever a creature is killed it drop's a currency that can be picked up by touching the "spot of interest"

It starts like this

local Interest = script.Parent
local Amount = script.Parent.Parent.Amount
local Gem = script.Parent.Parent
local deb = false

for i,v in pairs (Interest:GetTouchingParts()) do
	print(v.Name.." is the child of "..v.Parent.Name)
	if game.Players:GetPlayerFromCharacter(v.Parent) then
		print("Touched it")

Output is returning nothing.

1 answer

I believe GetTouchingParts() is not looped whatsoever.

So using :GetTouchingParts() way before anything has touched it will not detect anything, well because nothing is touching it.

What I'd do is if you're waiting for someone to be touching a part use .Touched, but if you need multiple people use :GetTouchingParts() but make sure to use it at an appropriate time maybe upon a set timer, a fired event, etc.

I hope this helped.

1 comment

0

Originally used the ".Touched" event and it wasn't working

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