I’m making a “class” system, where if the player clicks one of the buttons. It changes their maxhealth.
When I tested it, the maxhealth and health were changed to 125. But when the enemy attacked the player, it only took 4 hits (25 dmg) to kill the player. The enemy is an npc using :TakeDamage() to damage the player.
I’ve tried looking as hard I could for a few hours but I couldn’t find anything relating to this.
Hierarchy (Using Image Buttons)
Health Bar Local Script in StarterGui
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.HealthChanged:Connect(function(Damage)
script.Parent.Size = UDim2.new(Damage / humanoid.MaxHealth, 0, 1, 0)
end)
Juggernaut Local Script in StarterGui
local button = script.Parent
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local picked = game.ReplicatedStorage.ClassFolder.PickedClass --Bool Value to determine when player picked a class
local pickedJugg = game.ReplicatedStorage.ClassFolder.JuggernautBool --Bool Value to detect that player chose the juggernaut class
button.MouseButton1Click:Connect(function()
local human = char:FindFirstChild("Humanoid")
picked.Value = true
pickedJugg.Value = true
human.MaxHealth += 25
human.Health += 25
button.Parent.Parent.ClassFrame.Visible = false
end)
Sprinter Local Script in StarterGui
local button = script.Parent
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local picked = game.ReplicatedStorage.ClassFolder.PickedClass
local pickedSprinter = game.ReplicatedStorage.ClassFolder.SprinterBool
button.MouseButton1Click:Connect(function()
local human = char:FindFirstChild("Humanoid")
picked.Value = true
pickedSprinter.Value = true
human.Health-= 25
human.MaxHealth-= 25
button.Parent.Parent.ClassFrame.Visible = false
end)
Normal Script makes the class frame not visible.