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

How do I make the X axis move along with my IntValue?

Asked by 3 years ago

The script is supposed to make the X axis move based on the value of my IntValue


-- [Player Related Variables] -- local player = game.Players.LocalPlayer local level = player:WaitForChild("Level") local current = level:WaitForChild("Current") local max = level:WaitForChild("Max") -- [UI Related Variables] -- local gui = script.Parent local LevelFrame = gui:WaitForChild("Level Frame") local label = LevelFrame:WaitForChild("LVL") local exp = LevelFrame:WaitForChild("Exp Number") local bar = LevelFrame:WaitForChild("Frame") --[Changing Player Stats]-- label.Text = "Level "..level.Value exp.Text = current.Value.."/"..max.Value.." EXP" bar.Size = UDim2.new(current.Value/max.Value, 0, 1, 0) level.Changed:Connect(function(val) label.Text = "Level "..level.Value exp.Text = current.Value.."/"..max.Value.." EXP" bar.Size = UDim2.new(current.Value/max.Value, 0, 1, 0) end) level.Changed:Connect(function(val) exp.Text = current.Value.."/"..max.Value.." EXP" bar.Size = UDim2.new(current.Value/max.Value, 0, 0, 0) end)

1 answer

Log in to vote
0
Answered by 3 years ago

I might be wrong but you can try this.

I am also confused as to why you have 2 .changed events for the level...

-- [Player Related Variables] --
local player = game.Players.LocalPlayer
local level = player:WaitForChild("Level")
local current = level:WaitForChild("Current")
local max = level:WaitForChild("Max")
-- [UI Related Variables] --
local gui = script.Parent
local LevelFrame = gui:WaitForChild("Level Frame")
local label = LevelFrame:WaitForChild("LVL")
local exp = LevelFrame:WaitForChild("Exp Number")
local bar = LevelFrame:WaitForChild("Frame")
-- [Changing Player Stats] --
local formula = current.Value / max.Value
label.Text = "Level " .. level.Value
exp.Text = current.Value .. "/" .. max.Value .. " EXP"
bar:TweenSize(UDim2.new(formula, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0, true)

level.Changed:Connect(function(val)
    local formulaNew = current.Value / max.Value
    label.Text = "Level " .. level.Value
    exp.Text = current.Value .. "/" .. max.Value .. " EXP"
    bar:TweenSize(UDim2.new(formulaNew, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.5, true)
end)

Let me know if there are any issues, will try to fix immediately!

0
I honestly think if you just get rid of the second level.changed event your script will just work. The tweensize should just make it look better! tightanfall 110 — 3y
0
tightanfall, the script you posted didn't work, the x axis still wouldn't move Nateynate20 -2 — 3y
Ad

Answer this question