How Can I Make A Remote Event To Do This

I Wanna Make a Remote Event That Gives You Cash On A Leader Board

game.Players.LocalPlayer.leaderstats.DogeCoin.Value = Number


but i dont no how i would code that

1 Like

If I’m understanding your question correctly:
Edit: I accidentally set the value instead of adding it srry.


game.ReplicatedStorage.GiveCash.OnServerEvent:Connect(function(Player, NewValue)
local Value = Player.leaderstats.DogeCoin
    if NewValue then
        Value.Value += ToNumber(NewValue) --I'm using ToNumber() here just incase the remote event returns the value as a string.
1 Like

how would i fire this and set the cash number

1 Like

i know how to fire it but not set cash

1 Like

The following fires the remote event:

The following sets the value:

1 Like

does it add so the leaderboard

1 Like

Ok let me break this down for you

1)you need to know how to fire and receive message from client to server using remote events

you can message the server by writing
Amount is the Amount of cash you want the player to gain

now, you sent the message to give the player coins . We now need the server to listen for the message. you can do it by writing



the player value is set by default. Everytime you sent a message, the first argument will always be the player’s object . Take it this way , when you text somebody, their name always appear above or to the left of any message . The second argument (the variable called amount) is the data you sent from the client just now .

2)You need to know how to set , add or subtract values

to do that, you need the IntValue of the stats . assuming you know how to write a leaderstats script, you can get the IntValue by writing

local DogeCoinValue = player.leaderstats.DogeCoin

after you write that, you need to know how to set the value… setting the value should be direct . you simply write

player.leaderstats.DogeCoin.Value = 10

to set the value to 10

However , to add the value, it is a bit more challenging . you have to set the value of dogecoin to the value of dogecoin + the amount you want the dogecoin to gain Which would look like this

player.leaderstats.DogeCoin.Value = player.leaderstats.DogeCoin.Value + amount


player.leaderstats.DogeCoin.Value += amount

so now , you got to stack your burger and figure out how to do it . I already break it down for you ! programming is about thinking of solutions and I hope this will help you with your venture into programming. if you have any questions, feel free to ask

I do want to add - your way of solving this is vulnerable to exploits.

Exploiters are able to find RemoteEvents being fired, and if the name of the RemoteEvent is called “GiveMoney” it will be very obvious what that event will do.
Exploiters will then fire the RemoteEvent to the server with a custom value.

Possible vulnerability:

while task.wait() do
--//This will result in infinite money

Thus you should only manage the amount of money the player will get on the ServerScript’s side, since those scripts are inaccessible to exploiters. Yes it will be a bit harder to determine what exact value they should be getting, but it avoids your game being exploited.

oh ye using dex and remote spy Hmmm

i mean theres not alot of people playing it also i have anti-cheat in my game

the anticheat will most likely not combat this. Why do you need to give money on the clients demand?

If you use the code above you gave the the solution to, then your “anti-cheat” wont work. You’re plainly telling the server to give the amount of cash that the client tells the server to give them.

Client tells the server “give me 99999 money” and the server says “ok” without checking anything. How is your anticheat going to prevent this? You literally designed it this way

okay then how do i fix that???

it’s easy to do, first you need to make a remote for the server to handle the given the player their correct cash amount, so here’s the server script example…

--server script aka regular script NOT local

local remote = game.ReplicatedStorage:WaitForChild("Remote")-- this is the RemoteEvent we add in ReplicatedStorage

remote.OnServerEvent:Connect(function(player)-- the remote that got triggered already knows the player who triggered it so in brackets we add player, on server event is to handle to where if the remote got triggered then in this function here we will run this code
	local stat = player:FindFirstChild("leaderstats")-- the leaderstats we are trying to access
	local cash = stat.Cash -- this is the Cash we are trying to access
	if stat and cash then --let's check to see if stat and cash exist first before running the code we add in our if statement here
		cash.Value += 100 -- this is to add 100 cash basically to the player can subtract and more if needed

now the client part here

--Local Script aka Client script. NOT the server this script is added in a ScreenGui that Contains the
 --Button we will use

local player = game.Players.LocalPlayer -- this is the player who is triggering the remote we made

local remote = game.ReplicatedStorage:WaitForChild("Remote")-- this is the RemoteEvent we add in ReplicatedStorage

local Button = script.Parent.TextButton -- this is the button we will use to let the player click on it to then trigger the remote aka sending a message to the server.

Button.MouseButton1Click:Connect(function()--this is to handle where if the Button were to be Clicked on then we will connect a function basically
	if player then --a check to make sure the player exist first before Firing our remote
		remote:FireServer() --in the brackets we can add what we wanna send to the server to let server handle it if ever needed

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.