-
Hi, my intent is to make a coin system where a sole coin can be collected by every player on the server, but only once per player. I used a coin from the tool-box as a base and simply added a remote event to change the parts transparency on the client; it works as intended until a second player tries to pick up the same coin.
-- Script in workspace part
local db = true
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if db == true then
db = false
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1
script.Sound:Play()
game.ReplicatedStorage.CoinVisibility:FireClient(player)
end
end
end)
-- Local Script for part transparency
local player = game:GetService("Players").LocalPlayer
game.ReplicatedStorage.CoinVisibility.OnClientEvent:Connect(function(player)
game.Workspace.Coin.Transparency = 1
end)