RemoteFunctions: Commands code change?

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

It happened a long time without using remotefunctions, I attempted to a project during this week and it happens that RemoteFunctions have changed, in order to know more I used the Roblox Education Web, where I got the information that code for them now looks like this:

local Remote = game.ReplicatedStorage.RemoteFunction

Remote.OnServerInvoke = function(plr)
  print("test)
end

Alright, the iusse comes when trying to run them with commands, the old code in a normal script was:

local Remote = game.ReplicatedStorage.RemoteFunction

Remote.OnServerInvoke:Connect(function(plr, command)
if command == "test" then
  print("test)
else 
print("not test")
end
end)

The point is now that, using the new documentation code with commands it’s not working, for example I tried running this short code to test and nothing happens.

local Remote = game.ReplicatedStorage.RemoteFunction
Remote.OnServerInvoke = function(plr, command)
	if command == "a" then
		print(plr.Name .. "a")
	else
		print("b")	
	end
end

Local script code:

local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.RemoteFunction:InvokeServer(plr, "a")
end)

you should change the code in the local script because ‘plr’ itself will be added to the argument during the call from the local script, you can check this.

Local Script:

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.RemoteFunction:InvokeServer("a")
end)
1 Like

Thank you, I mean I have been 1 week investigating and it was just for ‘plr’, it makes me fell a little dumb, anyways have a great new year.