Client says one thing but server recieves it as something else

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make a system where you can purchase colora from the store

  1. What is the issue? Include screenshots / videos if possible!

The client has the price as 300 however the server recieves it as “Red” however I did not make anything equal to each other and there really seems to be no correlation.

As you can see it prints as “300” on the client but “Red” on the server.
image

Local script:

local price = script.Parent.Parent.price.Text
local TEXT = script.Parent:FindFirstChild("TextLabel").Text


script.Parent.MouseButton1Up:Connect(function()
	local plrcoins = plr.leaderstats.Coins
	if IsBought == true then
		print("true")
		part.Color = script.Parent.BackgroundColor
	else
		print("false")
		purchase.Text = "Confirm Purchase of "..TEXT.." for ".. "300".."?"
		confirmation.Visible = true
		confirmation.Yes.MouseButton1Up:Connect(function()
			if  plrcoins.Value >= tonumber(price) then
				event:FireServer(TEXT, key)
				confirmation.Visible = false
				print(price)
				valincrease:FireServer(price)
				print(price.."afer")
			else
				print("not enough coins")
			end
		end)
		confirmation.No.MouseButton1Up:Connect(function()
			confirmation.Visible = false
			confirmation.TextLabel.Text = "Confirm order of..."
		end)
	end
end)

Server Script:

Purchase.OnServerEvent:Connect(function(plr, price)
		print("ok")
	local coins = plr.leaderstats.Coins
	print(coins.Value)
	print(price)
	coins.Value -= tonumber(price)
end)```

maybe you set the coins on the client to something different, meaning only you see it and the server doesn’t

The client is sending two values:

event:FireServer(TEXT, key)

And the server is only accepting one value(price):

Purchase.OnServerEvent:Connect(function(plr, price)

This means that the server’s price is actually the client’s TEXT. To fix this either don’t send the TEXT to the server:

event:FireServer(key)

OR

Include the text in the server’s code:

Purchase.OnServerEvent:Connect(function(plr, TEXT, price)
2 Likes

Yep it worked in fact i got my events mixed up so thats what caused this issue; thanks!