So I'm making a collect-a-thon game however I have already hit a problem which is the fact that when I run the game only one person in the server can collect the items, once a player has collected the item, no one else can until the server is reset, I have tried to figure out what the problem is but to no avail so I ask you: How can I make this work? Do I need to use a local script or something else?
Bellow is the current script for my main collectable (no animation yet once you get it but this needs to be sorted out first).
local db = true
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if db == true then
db = false
script.Parent.Transparency = 0.125
script.Parent.CanCollide = false
script.Parent.Color = Color3.new(75,75,75)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.leaderstats2.Clapperboards.Value = player.leaderstats2.Clapperboards.Value + 1
end
end
end)
Also the script is with the part in the workspace. I.e Workspace -> clapperboard ->collecting script.
The way the script currently works stops the player who collected it from trying to collect it again which is what I want.
Edit: ok the db problem is solved but that brings up the problem of how to stop the first player who collected it form collecting it again, also I don't know how to change the properties of the object so it only changes for the player who collects it.

2 comments
You need to reset db. However if you do this, then the player can collect it multiple times. To fix this, add their name into a table, and check if their name is in there or not. If it is, don't let them collect it again.
You could also change the properties locally so that other players don't get confused with which ones they have collected already.