I am making a treasure hunt game in roblox can someone please write the script. I tried this but each player can infinitely collect the coin. I want it so that one player can collect it only once per game and then it is visible to other players who can also collect it. Please Help me.
COMMUNITY QUESTION
How to create a coin which gives points to all players but only once?
1 answer
Make sure filtering enabled is on then;
Add a remote event into replicated storage
Create the coin, add this script to tell when it is hit.
local players = game:GetService
script.Parent.Touched:Connect(function(hit)
local player = players:GetPlayerFromCharacter(hit.Parent)
local event = game.ReplicatedStorage.RemoteEvent --Change to event name
event:FireClient(player)
end)
Client side: Starter player scripts, starter gui etc
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
local cash = player.leaderstats.Cash -- Change to cash value location
cash.Value = cash.Value + 5 --Coins worth
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
If you adjust the Coins on the Client's end, the amendment wont replicate due to FE regulations. ROBLOX's Lua interpretation now supports shorthand operators too, so you can simply call: cash.Value += 5
I tried it but it just walks past the coin with no effect. No point was added