Candy Scavenger Hunt Not Working

For halloween I am making a candy scavenger hunt update. When you touch a candy it is supposed to delete itself on your screen but nobody else’s and the GUI is supposed to pop up neither is working though. Here are my scripts

This script is in ServerScriptStorage
Screen Shot 2020-10-17 at 11.08.00 AM

Then I have a remoteEvent in replicated storage

I also have a script in the GUI (which is in starterGUIS)

And then here is the folder with the candy that I put in workspace
Screen Shot 2020-10-17 at 11.07.38 AM

Any clue on what I am missing?

2 Likes

Wait. Is it Local? That means that it will only show up for the Local Player / the Client.
If yes, then I’m not sure. If no, then just put the Code into a LocalScript!
Good luck with your Halloween Update! :smile:

1 Like

The script in GUI is local the one in server script is not local

1 Like

Oh well. I’m not sure then, sorry.
Good luck. :sweat_smile:

2 Likes

You should make a localscript (in the candy part/model) where it for instance when touched, it’ll go transparent, non-collidable, and any other actions, which could apply for the GUI for instance.

1 Like

1st of all the player parameter is automatic so where is says

 game.ReplicatedStorage.FoundCandy:FireClient(plr,RandomCand.Name)

Remove the player parameter.
See if that works.

good to know but it didn’t help :frowning:

wait my candies are meshes would that impact it?

1 Like

Yes, it would still work, even if they’re meshes.

okay so I added something into the first script that made it so when it touched it would print test but it isn’t printing so something must be off about that

Keep in mind that it should be a localscript, and can I see the code?

Heres what I Have them set up as
Screen Shot 2020-10-17 at 12.01.58 PM

I have the candies all stored in a folder in workspace
then in ServerScriptStorage I have a normal script to detect if touched
Screen Shot 2020-10-17 at 11.08.00 AM
which fires the FoundCandy remote event (which is in rep storage)

that then triggers the local script inside of the guI

are u saying both need to be local if so where do I move the one in ServerScript to?

You’re checking if player is true, which is never as the player variable is the player.

Keep in mind :FireClient needs a player parameter to know which client should be fired.

Just check if plr isn’t nil, by doing the following:

if plr ~= nil then

Also, you’re only doing this on 1 candy. If you want all candies to do this, just use a for loop to loop through all candies and run the code.

1 Like

The .Touched:Connect funtion should be a localscript under the candy mesh.

1 Like

No, it should not. Firing clients must be done on the server. To be honest, you can just do the entire script in 1 local script if you only want it to display that they found the candy.

The entire code detecting that it’s being touched, then firing a Fireclient should be in the mesh.

Keep in mind localscripts do not run in workspace. They only run when they are descendant of the player, in a tool, or in the players character, or replicatedFirst.

You’re able to bypass this by the help of a script. ^^

wait where does the for loop part go?

You wanted the candy to disappear for the player who touches it, but still be visible to everyone else, correct?