Money is going to everyone in the server

Try this:

local MoneyEvent = game:GetService('ReplicatedStorage'):WaitForChild('MONEY')

MoneyEvent.Event:Connect(function(player)
	local Currency = player:WaitForChild("leaderstats"):WaitForChild("Currency")
	Currency.Value += 5
end)

What I changed:

  • I removed the PlayerAdded event because there’s literally no reason to have it (and it’s probably the reason this is broken)
  • I re-named “be” to “MoneyEvent”, because when your code gets larger you’ll want to be able to immediately recognize what is what
  • I put currency in .Event
  • I changed Currency.Value = Currency.Value + 5 to Currency.Value += 5

Let me know if that works.

1 Like

ok, looking at your original script

this is the fix it needs

local be = game.ReplicatedStorage.MONEY

be.Event:Connect(function(player)
	local Currency = player:WaitForChild("leaderstats"):WaitForChild("Currency")
	Currency.Value = Currency.Value + 5
end)

*** Just noticed, @GibusWielder posted the exact same changes. So theirs should work also.

maybe i’m wrong but maybe like that:

for the script money:

game.Player.PlayerAdded:Connect(function(p)
local stats = Instance.new('Folder',p)
stats.Name = 'leaderstats'

local argent = Instance.new('IntValue', stats)
agent.Value = 0
argent.Name = 'Money'

end)

for add money(I do that on a local script):

local player = game.player.LocalPlayer;
local leaderstats = player:WaitForChild('leaderstats')
local Money = leaderstats:WaitForChild('argent')

game.Players.PlayerAdded:Connect(function(player)
-- put here your script
end

Gonna try this when im home, I was sick for 3 days!

1 Like

Indeed lol Sorry for late reply I was sick for 3 days and when I get home im gonna try it

Alr gonna try this when im home, I was sick for 3 days!

Hello, just tried that and it give me a error in the console.

here is the error

hey, I just tried that and it give me a error in the console.

here is the error

I don’t think this would work, isn’t it gonna be easier for exploit to hack the money?

Is it a remote event or a bindable event? Try making it a remote event.

I can’t since the ray is from a script and script to script doesnt work with remote event if not wrong?

I think this should work.

-------StartVariable-----
local part = script.Parent

local myfirstray = Ray.new(part.Position, Vector3.new(0, 50, 0))

local zamboniHit = false
local mat = Enum.Material.Ground

local be = game.ReplicatedStorage.MONEY
-------EndVariable-------

while task.wait() or true do
	local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(myfirstray, {part})
	if hit then 
		if hit.Material == mat then
			part.CanCollide = false
			part.Transparency = 1
			be:Fire(game.Players.LocalPlayer.UserId)
			task.wait(5)
			part.CanCollide = true
			part.Transparency = 0
		end
	end
end

If it doesn’t work, I have no words.