So I’m kind of new at scripting (like 5 - 7 months of experience) and I need to use a remote event for a fall damage script. What I’m trying to do is send the amount of damage taken from the client to the server.
Here’s an example:
local damage = math.random(30,60)
player.Character.Humanoid.Health -= damage
I was trying something similar to this but I realized that’s not how remote events work, I have tried to search for help and I can’t figure out how to send a variable value through a remote event from the client to the server, can someone please explain it to me?
You should not be telling the server what the damage should be in any instance, ever.
That opens you up to exploit vulnerabilties.
Otherwise, I don’t see how that isn’t how remotes work. Looks normal to me for the most part.
What do you mean “sending a variable value?” In my experience thats exactly how you would do it
edit: obviously what @Synteuro said as well
If you are going to do that then check that the damage is a positive value so the client can’t deal negative damage to themselves
Yes, I know my game is vulnerable to exploiters but I’ll get into that later and do some research
Then I don’t see why it doesn’t work.
Ok so, while I was replying to your post I was kind of remaking the script and it works now, it’s fixed now. I don’t know what the error was though.
Thanks for the help of you both!
It’s possible you were firing the server before the “.OnServerEvent” event listener was properly hooked on the listening side. Take the following for example.
The local script fires the server as soon as it executes but the server script hasn’t hooked the corresponding “.OnServerEvent” event until 10 seconds have elapsed since the script’s execution. This means that the event is never fired.
I think the problem was that I was sending more than one argument through the remote event, I don’t know if you can actually do that
You can send as many as you like.
I think its because the server thinks what you defined as “player” is the “damage” you sent from the client
I could be wrong though
That’s not it. Server always knows from who is the message. Sending a player would make no sense. It would make sense only in cases when player does an interaction with other player, for example sending a party request or this kind of stuff.