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

In game pass script, health is being equal to the number value, i need it to be added/stacked, how?

Asked by 8 years ago
gps = game:GetService("GamePassService")
id = script:WaitForChild("GamePassID") -- number value
EH = script:WaitForChild("ExtraHealthAmount") -- number value

local function onVIPSpawned(player, character)
local human = character:WaitForChild("Humanoid")
human.MaxHealth + EH.Value -- it says it expects a '=' sign, but got a '+'
human.Health = human.MaxHealth
end

local function onPlayerAdded(player)
if gps:PlayerHasPass(player, id.Value) then
if player.Character then onVIPSpawned(player, player.Character) end
player.CharacterAdded:connect(function ()
onVIPSpawned(player, player.Character)
end)
end
end

for k, player in pairs(game.Players:GetPlayers()) do
onPlayerAdded(player)
end
game.Players.PlayerAdded:connect(onPlayerAdded)

On line 7 if i have human.MaxHealth = EH.Value, it works and changes the health to 50, but i need it to add 50, and human.MaxHealth + EH.Value doesn't work though. The 50 is the value i have for ExtraHealthAmount. So how do i make it stack up?

0
Please put your code in a code block so we can read it. MasterDaniel 320 — 8y
0
Done Supergamerboy1995 129 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Change Line 07 to:

local newHealth = humand.MaxHealth + EH.Value

Then change Line 08 to:

human.MaxHealth = newHealth
human.Health = human.MaxHealth

The reason your code does not work is because you are not setting the 'MaxHealth' value, you are simply making a value that gets deleted straight after it's made.

Hope I helped :)

~TDP

0
Yes you absolutely did, thank you! Supergamerboy1995 129 — 8y
0
No problem :) TheDeadlyPanther 2460 — 8y
Ad

Answer this question