Send informations by remote event or remotefunction

Send informations by remote event or filtering function >
ex: click the button and sends any money quantity by remote events,
and an script receives it informations and send it for player

I help vastly if you answer the questions provided in this post. Because your current post is lacking of much background information which makes it hard to understand what you want.

What are you asking for? Do you already have some code written?

argh, yes i already have it, but it doesn’t work so i came to ask for help, i’m trying to say a tool that when you click send information to the server through a remote event or a filteringfunction and then a script receives the information and gives the player a certain amount of money (i already have leaderstats)

Okay, please post your script so we can help you.

Tool script(when clicked sends quantity information to server)>

local tool = script.Parent
local player = script.Parent.Parent.Parent
local Debounce = false
local value = 500

tool.Activated:Connect(function()
if Debounce == false then
Debounce = true
game.ReplicatedStorage.FilteringFunction:InvokeServer(player, value)
wait(.5)
Debounce = false
end
end)

script that receives the quantity information:
(located on serverscriptservice)

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local RemoteEvents = ReplicatedStorage.RemoteEvents
local FilteringFunction = ReplicatedStorage.FilteringFunction

function FilteringFunction.OnServerInvoke(value, Player)

Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value + value
end

script that receives the quantity information:

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local RemoteEvents = ReplicatedStorage.RemoteEvents
local FilteringFunction = ReplicatedStorage.FilteringFunction

function FilteringFunction.OnServerInvoke(value, Player)

Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value + value
end

Can you put it in codeblocks by wrapping it in 3 backticks at the beginning and end?

-- this is a codeblock
1 Like

sorry, filtering function = remotefunction

First of all, sending a value to be increased or decreased from the client to the server is not the best idea because exploiters can manipulate them.
Paste this in your local script:

local tool = script.Parent
local player = game.Players.LocalPlayer
local Debounce = false

tool.Activated:Connect(function()
if Debounce == false then
Debounce = true
game.ReplicatedStorage.FilteringFunction:InvokeServer()
wait(.5)
Debounce = false
end
end)

and paste this in your server script:

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local RemoteEvents = ReplicatedStorage.RemoteEvents
local FilteringFunction = ReplicatedStorage.FilteringFunction

FilteringFunction.OnServerInvoke = function(Player)
local value = 500
Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value + value
end
3 Likes

Backticks are `, what you did was quoting. The first parameter for the .OnServerInvoke callback is the player who fired the remote so there is no reason to pass the player as an argument. As well, you are not returning anything in the callback function. If you do not need to send anything back to the client, you do not need to use RemoteFunctions, you can just use RemoteEvents. Also, you can just do Player.leaderstats.Coins.Value += value instead of rewriting the path. Also, there is no reason for you to define the value variable and send it to the server if it is already going to be constant. You can just do += 500 on the server.

i solved it myself by searching on hub