Problem firing remote evnts

Hello there, I have recently been trying to create my roblox game and I have run into a slight roadblock. It seems when I fire a remote event the variables are getting mixed up and it is not working as intended. The first script is a local script inside of a button which sends the player and amount of stuff they get through a remote event, the second script has the remote event as the child and prints what each value is. If anyone could help me I would appreciate it :smile:

script.Parent.MouseButton1Click:Connect(function()
	local personSad = game.Players.LocalPlayer
	local RebirthM = 0
	local PetM = 0
	local WorldM = 1
	local Amt = RebirthM+PetM+WorldM
	workspace.Main.RemoteEvent:FireServer(personSad, Amt)
end)
script.RemoteEvent.OnServerEvent:Connect(function(personSad, Amt)
	print(personSad)
	print(Amt)
end)

First parameter is always player that fired server in OnServerEvent.

You don’t need to send "personSad" to the server inside the :FireServer(). It is already there for you by default when using any remote so you can actually just do :FireServer(Amt).

1 Like

so is just like :OnServerEvent(player, Amt) with the script adding player automatically, or would I have to do something else?

Yes exactly first parameter is the player who fired the event.

Oh, (now I have to write more characters so roblox will allow this)

1 Like

and is parameter technically argument?

An argument is what you pass to a function/method’s specific parameter. A parameter is what the function is expecting to receive and handle inside the function itself if it has been specified by the programmer function Name(param1, param2)

Name(arg1, arg2)

Oh, ok that helps me understand. also thanks for helping the script works now!

1 Like