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

How do I make a brick remember who touched it?

Here is my dilemma: I want to make "discoverable" pearls in the new game I'm developing. Each time you find a pearl, it gives you +1 pearl in the leaderstats. The issue is I don't want the same player benefiting from the same pearl multiple times (i.e. standing on top of it and getting as many pearls as they want). I tried two things.

  1. I made it so that the pearl does not add to your leaderstats if you already touched it. -The problem: After one player has touched it, other players can not, and that pearl is useless on the server
  2. I made the pearls client-side, being inserted into the players camera. -The problem: This worked fine in "play solo", but as soon as I started a live version of the game it failed to work at all.

So in conclusion, I need a script that gives +1 leaderstats ONLY if it is that player's first time touching the part. The brick needs to remember who touched it and prevent that player from befitting from touching it again. I am stumped.

1 comment

0

option 1, set random points. option 2, only spawn a pearl when there are no players around e.g. < 20 studs do not add pearl.

1 answer

Hello.

Scripts that are parented to the LocalCamera will NOT work.

You would need to use a remote event or a local sided script in order to successfully run them.

Here is a quick example about what I'm talking about;Let's assume the Brick named "Pearl" is inside the LocalCamera already.

LOCALSCRIPT:

game.Workspace.CurrentCamera.Pearl.Touched:connect(function(h)
if h.Parent:FindFirstChild("Humanoid")~=nil then
--Your code would go here
end
end)

Hope this helps.

2 comments

0

Thank you, but this was not really the solution I was looking for. I went down the camera/local path and didn't really care for the way it was turning out. It seems like this issue delaying the rest of the game could be substantially expedited if the part just didn't allow the same player to touch/benefit from it twice

0

In the long run,it would be wiser for you to handle things such as this locally,on the client side.This will put less stress on the server,and it is generally good practice.Good luck with whatever you are working on!

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