RemoteEvent not sending correct data

I’m working on making a trade system and trying to send data from a local script to a server script.

Local Script

for i,v in pairs(playerShown:GetDescendants()) do
	if v:IsA("TextButton") then
		v.Activated:Connect(function()
			if debounce == true then
				debounce = false
				local playerTrading = v.Text
				local playerTrading = tostring(playerTrading)
				--playerTrading.Value = v.Text 
				local player = Players.LocalPlayer
				--playerTrading = playerTrading.Value
				tradeRequest:FireServer(player, playerTrading)
				print(playerTrading)
				wait(10)
				debounce = true 
			end
		end)			
	end
end

playerTrading is the person being sent a request to trade. When printed it prints out the correct player. So player1 for example.

Server Script

local function RequestedTrade(player, playerTrading)
	print(playerTrading)
	local player = Players[playerTrading.Name]
	local Requester = player 
	print(player)
	
	tradePopUp:FireClient(player, Requester)
end
tradeRequest.OnServerEvent:Connect(RequestedTrade)

If Player1 is supposed to be printed out for “playerTrading” it prints out player2 which is the the player sending the request. It also prints out player2 for both player and playerTrading.

Why is the data being changed and or not being sent properly?

On the client side, you dont need to provide the sender as an argument in FireServer, it’s automatically there.

3 Likes