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

The output displays an error when i try to detect if a number value has changed, how do i fix that?

Asked by
Echtic 128
5 years ago

This question has been solved by the original poster.

This is the script:

local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local magicbar = script.Parent.Parent
local magic = magicbar.MagicEBar
local textmagic = magicbar.Amount2
local startergui = game:GetService("StarterGui")
local magice = plr:WaitForChild("MagicEnergy")
local maxmagice = plr:WaitForChild("MaxMagicEnergy")

local function update()
 magic:TweenSize(UDim2.new(0, magice.Value / maxmagice.Value * 395, .38, 0), "Out", "Quad", 0.1, true)

 textmagic.Text = math.floor(magice.Value).."/"..math.floor(maxmagice.Value)
end

magice.Value.Changed:Connect(update)
update()
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)

It's a local script since it's related to the Gui.

The output displays this error:

Players.iiiAmericanLight.PlayerGui.MainGui.HpMagicFrame.Background.MagicEBar.ValueScript:18: attempt to index field 'Value' (a number value)

1
If the variable magice is the value object then remove the Value. Changed is an event for the instance not the number returned by .Value User#5423 17 — 5y
0
You are a god, type that as an answer so i can accept it.You need to get rewarded xD Echtic 128 — 5y
0
Its ok. User#5423 17 — 5y
0
@kingdom5 is correct, as you can ONLY change/read the Value property, but not the actual Value instance (acts like (almost) any other instance). GamingZacharyC 152 — 5y
0
magice.Value.Changed:Connect(update) won't work, use magice:GetPropertyChangedValue("Value"):Connect(update) despicablejack2005 83 — 5y

Answer this question