I have a remote event and the script below in a local script to remove a coin for a player when they collect but it’s removing for all players and I am not certain why?
– ServerScript under Part in Workspace
local Value = 1
local Enabled = true
local repStorage = game:GetService(“ReplicatedStorage”)
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.Coins.Value = lstats.Coins.Value + Value
Enabled = false
script.Parent.Transparency = 1
local playerSound = repStorage:WaitForChild("PlaySound")
playerSound:FireClient(Player, 1)
local collectCoin = repStorage:WaitForChild("CollectCoin")
collectCoin:FireClient(Player, script.Parent)
end
end
end)
– Local Script inside StarterPlayerScripts
game.ReplicatedStorage.CollectCoin.OnClientEvent:Connect(function(coin)
coin:Destroy()
end)
Did you update the script? Try putting a print function inside the localscript’s .OnClientEvent scope to see if it does fire for both players. If so, this might be a roblox bug
Remove the script.Parent.Transparency = 1 line inside the server script, that way it’ll disappear on the client who collected the coin but on the server it will stay visible