Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Max Health increase in studio works perfectly but...?

Asked by 6 years ago
Edited 6 years ago

Whenever I increase max health in studio when a stat is changed, the health regens to the max health. However, in the actual game, the health only regens up to 100 regardless of how much the max health is. Here is the script:

001player = game.Players.LocalPlayer
002local Str = player.Stats.Strength.Value
003local Agi = player.Stats.Agility.Value
004local Int = player.Stats.Intelligence.Value
005local Def = player.Stats.Defense.Value
006local Vit = player.Stats.Vitality.Value
007local Dex = player.Stats.Dexterity.Value
008local Damage = 0
009local Speed = 0
010local Critical = 0
011local CriticalDamage = 0
012local weapon
013 
014function damage()
015    for j,k in pairs(player.Equip:GetChildren()) do
View all 104 lines...

So I tried this in my local script

1if x == "Strength" then
2        game.ReplicatedStorage.AddHealth:FireServer()
3        script.Parent.Parent.Information.HP.Text = "HP: " .. tostring(player.Character.Humanoid.MaxHealth)
4        script.Parent.Parent.Information.ATKDMG.Text = "ATKDMG: " .. tostring(Damage)
5    end

and in my server script in workspace

1game.ReplicatedStorage.AddHealth.OnServerEvent:connect(function(player)
2    player.Character.Humanoid.MaxHealth = player.Character.Humanoid.MaxHealth+2
3end)

it says AddHealth is not a valid member

2 answers

Log in to vote
0
Answered by 6 years ago

If you're using FilteringEnabled, you'll need to do that in a Script instead of a LocalScript.

1
How would I find the local player from a server side script? xxXTimeXxx 101 — 6y
1
You can send it over using a RemoteEvent. AvatarAang400 35 — 6y
0
Can you give me an example? I kept reading about using remoteevents as a means to get the player from a server-side script but I never seemed to find any non-complicated guide xxXTimeXxx 101 — 6y
2
Put a remote event into your Replicated Storage. In your local script, call it like: game.ReplicatedStorage.RemoteEvent:FireServer(). In your server, have a function that is triggered by game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(). Then, do whatever you need to in that function and you will have the player variable. AvatarAang400 35 — 6y
View all comments (4 more)
1
Okay thanks i'm gonna try that as soon as i finish eating lunch xxXTimeXxx 101 — 6y
0
Edited the code xxXTimeXxx 101 — 6y
0
Nvm lmao you needed to create the AddHealth remoteevent in the storage xD thanks xxXTimeXxx 101 — 6y
0
No problem! AvatarAang400 35 — 6y
Ad
Log in to vote
1
Answered by 6 years ago
1--You cant use
2 
3game.Players.LocalPlayer
4 
5--In a script you can only use it in a local script

Answer this question