Does anyone know how I could get the size of a frame (from the x axis) and change its value with the ‘int value’?
I need to use the ‘int value’ to change its value to my liking and make this value show in the frame when I change this int value… how could i do that?
Scale is the value that takes uses a percentage of the screen size. You could do something like this, changing the intvalue’s value to anything between 0-100 will change the frames size.
local intvalue = --define
local frame = -- define
local ydefault = --number 0 - 1, how big it should be on the y axis.
intvalue.Changed:Connect(function()
if intvalue.Value <= 100 and intvalue.Value >= 0 then
frame.Size = UDim2.new(intvalue.Value/100,0,ydefault, 0)
end
end)
while wait(1) do --just to test if it changes
intvalue.Value = math.random(1,100)
end
local intvalue = --define
local frame = -- define
local ydefault = --define default y pixels
intvalue.Changed:Connect(function()
frame.Size = UDim2.new(0,intvalue.Value,0, ydefault)
end)
while wait(1) do --just to test if it changes delete this if you want
intvalue.Value = math.random(1,500)
end
local intvalue = Instance.new("IntValue")
intvalue.Name = "Stamina"
local frame = script.Parent
local ydefault = 1
intvalue.Changed:Connect(function()
frame.Size = UDim2.new(0,intvalue.Value,ydefault, 0)
end)
while wait(1) do --just to test if it changes delete this if you want
intvalue.Value = math.random(1,500)
end
I just did it and it shows me that 100 is half the bar
local intvalue = Instance.new("IntValue")
intvalue.Name = "Stamina"
local frame = script.Parent
local ydefault = 1
intvalue.Changed:Connect(function()
frame.Size = UDim2.new(0,intvalue.Value,ydefault, 0)
end)
intvalue.Value = 100
--while wait(1) do --just to test if it changes delete this if you want
--intvalue.Value = math.random(1,100)
--end
Instead of using pixels I would use scale. 100 is full bar 0 is empty. Later today after school I’m going to make a Community Tutorial on a sprint bar gui, maybe that could help too.
local intvalue = Instance.new("IntValue")
intvalue.Name = "Stamina"
local frame = script.Parent
local ydefault = 1
intvalue.Changed:Connect(function()
frame.Size = UDim2.new(intvalue.Value/100,0,ydefault, 0)
end)
intvalue.Value = 100
--while wait(1) do --just to test if it changes delete this if you want
--intvalue.Value = math.random(1,100)
--end
Can I ask you one last question? I would like to know that my code is wrong, if you could help me with this it would really be the last thing for today I am ready
local intvalue = Instance.new("IntValue")
intvalue.Name = "Stamina"
local frame = script.Parent
local ydefault = 1
intvalue.Changed:Connect(function()
frame.Size = UDim2.new(intvalue.Value/100,0,ydefault, 0)
end)
intvalue.Value = 1
local stamina = intvalue.Value
if stamina >= 0 then
for i = 0, 50, 5 do
stamina = i
print("Part 1. stam is: " .. stamina)
wait(2)
if stamina >= 50 then
print("end of part 1.")
wait(2)
for i2 = 50, 100, 5 do
stamina = i2
print("Part 2. stam is: " .. stamina)
end
end
end
end