I'm having problems with the remote event (server - client), is sending the values in the wrong order and some are nil

I tried FireClient I used Fire:Client for the server with values ​​(player, stat, amoun), but when using print I saw that the values ​​are coming wrong and some null

Server code:

    local ReplicadeStorage = game:GetService("ReplicatedStorage")
local Events = ReplicadeStorage.ManualTraining
local ShowGui = Events.ShowGui
    
    local function increaseStats(player,Amount,Stat)
	while TrainModule.GetTraining(player)["Training"] == true do
		wait(1)	 
		if ServerData[player.UserId] == nil then
			
		else	
		ServerData[player.UserId]["Stats"][""..Stat]["Value"] = ServerData[player.UserId]["Stats"][""..Stat]["Value"] + 50
		ShowGui:FireClient(player,Amount,Stat)
		print(ServerData[player.UserId]["Stats"][""..Stat]["Value"])
		end
	end
end

Obs: the stat = “Endurance”, and Amount = 50 (ik beacause i already printed, and the value is correct)

But on my local script inside TextLabel

local ReplicadeStorage = game:GetService("ReplicatedStorage")
local Events = ReplicadeStorage.ManualTraining
local ShowGui = Events.ShowGui

local function guiPoints(player,amount,stats)
	local pos1 = math.random(140,500)
	local pos2 = math.random(109,250)
	    print(amount) //Here 
		script.Parent.TextLabel.Text = tostring(50)
		script.Parent.TextLabel.Position = UDim2.new(0,pos1,0,pos2)
		script.Parent.TextLabel.Visible = true
		wait(0.50)
		script.Parent.TextLabel.Visible = false
		
		
end

ShowGui.OnClientEvent:Connect(guiPoints)

Is printing that

where was to be the value of Amount is sending the name of the Stats, where was to be the Stats is sending the player, and where was to be the player is sending Nil (i know because i printed all values)

1 Like

The server requires the first argument of FireClient to be the player who is to receive the signal from the server that they should be doing something. The client does not receive this argument. Remove the player parameter from OnClientEvent and try again.

In the future, to test why you’re receiving nil or what your arguments are, make sure to add a print statement underneath to print out the values of all variables. You’ll be able to better understand what’s occurring.

2 Likes

i already tested “where was to be the value of Amount is sending the name of the Stats, where was to be the Stats is sending the player, and where was to be the player is sending Nil (i know because i printed all values)”, now this error

1 Like

You misunderstand what the previous user is saying, the Server requires the player argument :FireClient(Player, Args)

However OnClientEvent:Connect(function(Args) end) the client doesn’t receive this argument.

2 Likes

Só What i need tô do ? Please idk

remove the word player, from here. It should just be

local function guiPoints(amount, stats)
2 Likes