How to make it so when a player touches a part, they get a "coin"

You should avoid using the parent argument in instance.new because this requires more internal calls thus making it bad for performance. Instead you should change all the necessary properties in the object and then parent the object as the last thing you do. See here: PSA: Don't use Instance.new() with parent argument

As another side note you should be using a folder instead of a BoolValue for creating leaderstats.


For your question you could attach the .Touched event to each part used to increase coins, this event fires wherever the part is touched by another part. Then each time one of these parts is touched check if a player touched the part by checking for a HumanoidRootPart. Once you know a player has touched the part get the player instance from the character using GetPlayerFromCharacter and increase the coins in the leaderstats.

3 Likes