MaxHealth ignored when player takes damage

  1. What do I want to achieve?
    I want to make it so when a player picks a certain class (in this case; Tank) their maxhealth is increased so that when they take damage they can take more hits til they die.

  2. What is the issue?
    Whenever the player takes damage (after having selected the class) their new max health value gets ignored, setting it to 100.

  3. What solutions have I tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried looking on resources like youtube, but haven’t found much help. I’ve also looked at similar posts on the forums.

Here’s a function I made to give the player stats for the Tank class, everything else works besides the Health / MaxHealth. Just wondering, seeing as I’m fairly new to scripting, if I missing something.

2 Likes

from the look of things you are changing the max health via the client, you have to change it via the server cause thats where damage should be handled, also changing it on the client means no other players can see that change, and again the server cant either

2 Likes

Okay, ill give it a try. Might have to rearrange some things for it to work, but shouldn’t be too bad. I’m just messing around testing currently for a system I plan to implement. Thanks for the help! The local script is in startcharacter scripts, can I put a server script here?

1 Like

You could use a remote event inside of that event, like fire to the server inside of that client event. I think you know what I mean.

1 Like

well where ever you send the remote event to the client, you could change it there

1 Like

Oh I could fire an event to a script in serverscript service to change the players health from the local script?

I think it’s working now! Tysm for the help, what I did was fire a new event called TankHealth from the local script shown instead of changing the humanoid values there. Then I made a script in ServerScriptService (TankHealthScript) where I then changed the values of the humanoid. I tested it out on an attacking dummy and it works! Thanks for helping! This also explains why some of my other scripts dont work :stuck_out_tongue: Have a good one!

1 Like

I meant, on the “ClientEvent” you can write :FireServer() within it.

1 Like

I see what you mean, I went from a server script to local to another server script. I’ll try to clean things up. Thanks for the help btw :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.