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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
4 years ago

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.

0
Originally used the ".Touched" event and it wasn't working songboy50 77 — 4y
Ad

Answer this question