How can I fix this? Some of my candies don't pick up

Hello fellows people! The video below shows my issue. I have the “candy” currency in my game where everytime a player picks up a candy it disappears & the value of their candies go up

Here’s the video

image
This is the coin script thats making it work (its a local script in StarterCharacterScripts) ^

image
And this is in the server script service ^

Basically in the last photo I added that to my obby checkpoint system that already contains the leaderstats

I would appreciate any guidance or help very much :slight_smile:

1 Like

Also the candy parts are parts… I just added “special mesh” to it. Maybe thats the issue?

1 Like

First of all I recommend moving the variables you re-use outside of the pairs loop. Player, char, Value… No need to redefine them with every loop since they don’t change.

Do the candies spawn dynamically through a script? Or did you put them in place manually on Studio?

1 Like

You definitely shouldn’t give values on a local script, also is the candy a model? And does the candy have the correct tag?

Also the “Coin” and “Touched” variables arent used in the script :man_shrugging:

1 Like

Also the issue is, the parts arent loaded in time. Try setting a task.wait(5) before starting the loop.

1 Like

i placed them manually in my workspace in a folder

1 Like

hey i appreciate the response. the candy does have the correct tag. I did forget to mention I am not experienced with scripting :sob: so if the coding looks dumb thats why lol

How would I add the coin and touched variables in?

1 Like

you dont need to, did the wait(5) work?

2 Likes

Drag your whole code and put it inside a server script inside server script service, and get the player using hit.Parent with method: :GetPlayerFromCharacter(hit.Parent) and add the values on the server, and also if you are not going to use the candy, destroy it instead of hiding it, if you do enough search, you will know how to get the player from the Touched event since you are new, if you want to hide the candy for the player only fire a remote event to the client with the candy as a parameter and destroy it on the client.

2 Likes