So in my game, I have Coins. When a player touches those coins, I want them (the coins) to be destroyed locally. But the coins should be still visible to the players who haven't yet touched it.
The Coins live inside the Workspace.
My code right now makes the coin invisible for 10 seconds when a player touches it, but it makes it invisible for every player in the game.
I want it so that the player who touches a coin (so that they can get +1 point in their leader board), that coin should be destroyed locally for them only.
I am not quite understanding how to do that.
What I tried:
I have tried to put the same script inside startergui but with a local script. But that doesn't help as well.
My Code:
The Collect Script inside the coin (it is not a local script):
local db = true
local Cooldown = 10
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if db == true then
db = false
script.Parent.Transparency = 1
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1
script.Sound:Play()
wait(1)
script.Parent.Transparency = 1
wait(Cooldown)
script.Parent.Transparency = 0
db = true
end
end
end)
Thanks for any help
