so ive got a script that when a coin collects it adds one to leaderstats stats and shows money on gui
but when theres 2 players and somebody gets it it shows to everyone heres the script (local script btw)
local player = game.Players.LocalPlayer
local ringslabel = script.Parent
local Rings_Folder = game.Workspace.RingsFolder
local cangetcoin = true
local CDCoin = 0.1
local Amount_Rings_Value = 1
local Amount_Particle = 10
local RingParticleFolder = game.Workspace.RingParticlesFolder
local RingSound = script.RingEffect
local DB = false
local Amount_Circle_Particle = 1
local ParticlePart = RingParticleFolder.RingParticle
local leadercubes = player.leaderstats.Cubes
leadercubes.Changed:Connect(function(val)
if player then
ringslabel.Text = "Cubes: ".. val
end
end)
ringslabel.Text = "Cubes: ".. leadercubes.Value
for i, v in pairs(Rings_Folder:GetChildren()) do
v.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
local particle_cloned = false
if hum and DB == false then
DB = true
v:Destroy()
if particle_cloned == false then
particle_cloned = true
ParticlePart.Position = v.Position
ParticlePart.Particle:Emit(Amount_Particle)
ParticlePart.Particlecircle:Emit(Amount_Circle_Particle)
if cangetcoin == true then
cangetcoin = false
leadercubes.Value += Amount_Rings_Value
RingSound:Play()
end
wait(CDCoin)
DB = false
cangetcoin = true
v:Destroy()
end
end
end)
end