Add Property To Object

so i figured out how to link it i linked the script and got the gui to work so when my health goes down so does my power level bar but i still cant figure out this Attribute stuff

i finally did it
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local UserInputService = game:GetService(“UserInputService”)
local PowerBar = script.Parent.PowerBar.Bar

local Stamina = 100
local Running = false
local SprintSpeed = 30
local WalkSpeed = 16
local MaxPower = 100
local IsPromptActive = false

PowerBar.Size = UDim2.new(0, 0, 1, 0) – Start with an empty power bar

– Create a custom attribute “Power” in the player’s humanoid
local humanoid = Character:WaitForChild(“Humanoid”)
humanoid:SetAttribute(“Power”, 0) – Start with 0 power

– Create the ButtonPrompt text label
local ButtonPrompt = Instance.new(“TextLabel”)
ButtonPrompt.Name = “ButtonPrompt”
ButtonPrompt.Size = UDim2.new(0, 100, 0, 50)
ButtonPrompt.Position = UDim2.new(0.5, -50, 0.8, 0)
ButtonPrompt.BackgroundColor3 = Color3.new(0, 0, 0)
ButtonPrompt.BackgroundTransparency = 0.5
ButtonPrompt.BorderSizePixel = 0
ButtonPrompt.Text = “[E]”
ButtonPrompt.TextColor3 = Color3.new(1, 1, 1)
ButtonPrompt.TextSize = 24
ButtonPrompt.Visible = false – Initially hide the text label
ButtonPrompt.Parent = script.Parent – Set the parent of ButtonPrompt to the same as the script’s parent

local function ShowPrompt()
local promptAction = UserInputService.PromptGameAction(Enum.KeyCode.E)
promptAction.Text = “Press E to continue”
promptAction.Image = “” – You can set an image here if desired
promptAction.ActionTriggered:Connect(function()
humanoid:SetAttribute(“Power”, 0) – Reset power
PowerBar.Size = UDim2.new(0, 0, 1, 0) – Reset power bar
promptAction:Remove()
IsPromptActive = false
ButtonPrompt.Visible = false – Hide the text label
end)
promptAction:Create()
IsPromptActive = true
ButtonPrompt.Visible = true – Show the text label
end

local function UpdatePowerBar()
while true do
if not Running and PowerBar.Size.X.Scale < 1 then
local currentPower = humanoid:GetAttribute(“Power”)
if currentPower < MaxPower then
humanoid:SetAttribute(“Power”, currentPower + 1)
PowerBar.Size = UDim2.new(PowerBar.Size.X.Scale + 0.01, 0, 1, 0)
PowerBar:TweenSize(UDim2.new(PowerBar.Size.X.Scale, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1, true)
elseif currentPower >= MaxPower and not IsPromptActive then
ShowPrompt()
end
end
wait(0.1)
end
end

– Start the power bar update loop
spawn(UpdatePowerBar)

– Rest of your script for power regeneration

Sounds good.
Please don’t reply to yourself when trying to reply to another person. I didn’t get any notifications of your replies.

I only just read the Attribute information documentation when you asked this question, and they seem pretty self-explanitory to me. I did write my section of code with power instead of Power so I don’t know if that messed you up.

An Attribute is a simpler way of adding something like a value to a player (like an IntValue, a BoolValue, or any other type) and then setting the Value of that item (IntValue.Value) to something.

I don’t know if can set an AttributeChanged signal though. I’d have to read up on that.