Problem
The problem is, you are using .Value in variables, this not update the value in variable, for fix you need to get value in loop, not in variable.
Examples:
local MyValue = workspace.MValue.Value
while true do
MyValue = workspace.MValue.Value
print(MyValue)
wait()
end
local MyValue = workspace.MValue
while true do
print(MyValue.Value)
wait()
end
Correction
Its simple, only remove .Value from variable and put it on get the value:
local Bar = script.Parent
local Value = script.Parent.Parent.Enrg
while true do
Bar.Size = UDim2.new(Value.Value/100,0,1,0)
wait(0.01)
end
Also you can detect if value changed with Instance.Changed
- This simple detect if Anything in object changed.
Example:
local obj = workspace.MyValue
obj.Changed:Connect(function()
print("Changed the Value of " .. tostring(obj.Name) .. "!")
end)
For your script is here:
local Bar = script.Parent
local Value = script.Parent.Parent.Enrg
Value.Changed:Connect(function()
Bar.Size = UDim2.new(Value.Value/100,0,1,0)
end
Hope it helped, Errors? tell-me on comments
Wiki pages
Changed
Solved your problems? Accept a answer or put [SOLVED] in title
3 comments
maybe this will help??: change Value to script.Parent.Parent.Enrg and line 5 to UDim2.new(Value.Value/100,0,1,0)
Thank you!!! XD
As a note, using a while loop here is pretty inefficient. You may want to consider using the .Changed event instead. API link: https://developer.roblox.com/api-reference/event/NumberValue/Changed