Sending a number from local script to server script

hello!
im a beginner with remote events and i dont quite get them. please help, thanks

my code:

--local script
script.Parent.MouseButton1Click:Connect(function()
	local number = 50 
	local rs = game:GetService("ReplicatedStorage")
	local re = rs:WaitForChild("RemoteEvent")
	re:FireServer(number) 
	print("sended")
end)
--server script
local rs = game:GetService("ReplicatedStorage")
local re = rs:WaitForChild("RemoteEvent")

re.OnServerEvent:Connect(function(number)
	print("received number: "..number)
end)

The first parameter of any RemoteEvent is the Player that has fired it. Try adding a “Player” parameter before the “number” one. This should make it work.

local RS = game:GetService("ReplicatedStorage")
local RE = RS:WaitForChild("RemoteEvent")

RE.OnServerEvent:Connect(function(Player, number)
	print("Received number: "..number)
end)
1 Like

you made my day! thank you a lot!!!