Hey, I have an XP bar in which I want the XP goal to increase by the players level * 15 every time they level up. But the problem is that the bar just stays on the 0% mark and doesn't move at all.
Any ideas on how to fix it?, Thanks, Cuv
player = game.Players.LocalPlayer l = player:FindFirstChild("leaderstats") xvalue = l:FindFirstChild("XP") levelv = l:FindFirstChild("Levels") mathlevel = (levelv.Value * 15) local PositionX = script.Parent.Position.X.Scale local initX = script.Parent.Size.X while true do wait(0.1) local CurrentXP = xvalue.Value local XPTarget = CurrentXP / mathlevel script.Parent.Size = UDim2.new( 0, XPTarget, 0, 15) script.Parent.Position = UDim2.new(0.5, -100, 0.9, -20) end
You should use the .Changed function, here is an example, for your script:
player = game.Players.LocalPlayer l = player:FindFirstChild("leaderstats") xvalue = l:FindFirstChild("XP") levelv = l:FindFirstChild("Levels") mathlevel = (levelv.Value * 15) local PositionX = script.Parent.Position.X.Scale local initX = script.Parent.Size.X levelv.Changed:connect(function(p) --p is the property that changed if p.Name == "Value" then xvalue.Value = xvalue.Value * 15 script.Parent.Size = UDim2.new( 0, XPTarget, 0, 15) script.Parent.Position = UDim2.new(0.5, -100, 0.9, -20) end end)
Hope this helped, and if it did, don't forget to accept the answer, it gives us both rep