I'm trying to make my game filtering enabled, but I'm having a whole lot of troubles with remoteevents.
Let's say I wanted to do a 'Damage' event. I tried this script:
script.Damage.OnServerEvent:connect(function(player,value) game.Players[player].Character.Humanoid.Health = game.Players[player].Character.Humanoid.Health - value end)
Now, that wouldn't work, because player and value would be the same thing, leading me to my question. How would I add arguments to a remote event?
I can't seem to get this one. All help appreciated!
A RemoteEvent being fired from the client automatically sends the first argument, as the player. By 'Player', it's referring to the Instance of a Player.
script.Damage.OnServerEvent:connect(function(player,value) player.Character.Humanoid.Health = player.Character.Humanoid.Health - value -- since player is already a child of 'game.Players', I can directly referrence it. end)
When you do :FireServer() you don't need to do :FireServer(game.Players.LocalPlayer, 10) since the first argument is automatically recieved. So if you do
remote:FireServer(10)
The value would be 10
remote.OnServerEvent:connect(function(playerWhoFired, Damage) print(Damage) --// 10 end)
playerWhoFired is the player object so you can just do playerWhoFired.Character or your way it would be game.Players[playerWhoFired.Name].Character