Stats script not working

  1. What do you want to achieve?
    Im trying to make an RPG level up system, where the player can upgrade their stats when they press the GUI button

  2. What is the issue?
    Whenever they press the button, the GUI gets hidden, but the health and jump power don’'t change.

  3. What solutions have you tried so far?
    I added a print to the script and it still prints the message, but the stats dont change.

image

Not working script
local player = game:GetService("Players").LocalPlayer -- Defines the local player
local health = player.Character.Humanoid.MaxHealth -- Defines the player's health
local jump = player.Character.Humanoid.JumpPower -- Defines the player's jump power

script.Parent.MouseButton1Click:Connect(function() -- Activates the function once the stats button is pressed
	script.Parent.Parent.Visible = false -- Disables the level up screen
	health = health + 15 -- Increases the player's health by 15
	jump = jump + 5 -- Increases the player's jump power by 5
	print("pls print me") -- Print in the log for testing
end)

Both health and jump just hold the original number, and do not actually change the humanoid when it is changed. Create one variable for the humanoid, then set the JumpPower and MaxHealth then.

local humanoid = character.Humanoid
humanoid.MaxHealth = 120
1 Like

You are changing your “jump” variable without assigning it to the JumpPower of the player.
Heres a corrected version of your script with a bit optimization

local player = game:GetService("Players").LocalPlayer -- Defines the local player

script.Parent.MouseButton1Click:Connect(function() -- Activates the function once the stats button is pressed
	script.Parent.Parent.Visible = false -- Disables the level up screen
	player.Character.Humanoid.MaxHealth += 15 -- Increases the player's health by 15
	player.Character.Humanoid.JumpPower += 5 -- Increases the player's jump power by 5
	print("pls print me") -- Print in the log for testing
end)
2 Likes

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