Can't get a local number to fire to the server

So I started working on this game, where there is a wage the Mayor can change, it’s similar to Generic Roleplay Gaem, except it is a town. I can’t get the wage the Mayor inputs locally to the server, I have tried everything including RemoteEvents.

Here is what the code looks like:
Local:

local event = game.ReplicatedStorage.WageChange

local wage = script.Parent.Value

event:FireServer(wage)

Server:

local remoteevent = game.ReplicatedStorage.WageChange

remoteevent.OnServerEvent:Connect(function(wage)

   script.Parent.Value = wage

end)
1 Like

By default the first argument passed by OnServerEvent is the player that called it

Try:

local remoteevent = game.ReplicatedStorage.WageChange

remoteevent.OnServerEvent:Connect(function(player, wage)

   script.Parent.Value = wage

end)

For some reason it still isn’t working, the script inside the player’s gui should be local right?

You have to listen for wage value changes:

local wage = script.Parent --no .Value!(it makes it constant)

function Changed(value)
	event:FireServer(value)
end

Changed(wage.Value)
wage.Changed:Connect(Changed)

Where should the event be? I tried this as well just now, It didn’t work. I got no errors or anything, I tried print() debugging, and it sent a print from your script the second the game starts, no other time. The server wasn’t printing. So for some reason it is not going from the client to the server.

local event = game.ReplicatedStorage.WageChange

I put that in there as well, when I used your script.

Are you using a LocalScript and are there any errors showing?

Yes, there are no errors inside the output box so none that I can see.
Do you think it is something to do with the server?

local remoteevent = game.ReplicatedStorage.WageChange

remoteevent.OnServerEvent:Connect(function(wage)

	script.Parent.Value = wage
	print("Wage has changed!")
	
end)

this isn’t related to the problem but I do advise using :WaitForChild("") and :GetService("") in the localscript.

to save you from future errors with loading

Okay, I will try inputting that into it.

1 Like

The player parameter is passed by default. So it must be function(player, wage).

Is this supposed to go into the local script?

Edit:
I saw where I was supposed to put and I put it there in the server script, still isn’t working with no errors.

1 Like

I’m a bit late to the party.

If I understood correctly, you are trying to fire to the server a value that was set locally?

Yes, and so far I’m not getting any errors from any of the scripts. It just isn’t sending.

How do you get the value? Is it from a TextBox?

It is from a number value inside the text.

Can you send me what the explorer looks like?

Just edited the one above to show that.

Local

wait(2)
local event = game.ReplicatedStorage:WaitForChild("WageChange")
local wage = script.Parent.Value

print(wage)

event:FireServer(wage)

Server

local event = game.ReplicatedStorage:WaitForChild("WageChange")
event.OnServerEvent:Connect(function(player,wage)
	script.Parent.Value = wage
end)

A problem I encountered is that you did not set the player on the ServerEvent function.
If it does not work, please show me the output.