Here's the script
local Value = 10 local Enabled = true script.Parent.Touched:Connect(function(hit) if Enabled then local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player then local lstats = Player:WaitForChild("leaderstats") lstats.Gold.Value = lstats.Gold.Value + Value Enabled = false script.Parent.Transparency = 1 if script.Parent:FindFirstChild("Sound") then script.Parent:FindFirstChild("Sound"):Play() end end end end)
Right now, when a player collects the coin it disappears, but no other players can collect the coin. How would I make it so the coin only disappears on the player's screen (the player who touched the coin), but not on anyone else's?
local Value = 10 local Enabled = true script.Parent.Touched:Connect(function(hit) if Enabled then local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player then local lstats = Player:WaitForChild("leaderstats") lstats.Gold.Value = lstats.Gold.Value + Value Enabled = false script.Parent.Transparency = 1 if script.Parent:FindFirstChild("Sound") then script.Parent:FindFirstChild("Sound"):Play() end game.ReplicatedStorage.destroycoin:FireClient(Player,script.Parent)--send to the player it picked up the coin end end end)
local script here
game.ReplicatedStorage.destroycoin.OnClientEvent:Connect(function(coin) coin:Destroy()--destroys the coin on the client side only end)