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

Why won't my UDim2 Script tween based on player EXP?

Asked by 9 years ago

P = script.Parent.Parent.Parent.Parent P.leaderstats.EXP.Changed:connect(function() if P.leaderstats.EXP > (P.leaderstats.MaxEXP) then P.leaderstats.Level.Value = P.leaderstats.LastLevel.Value + 1 P.leaderstats.EXP.Value = 0 P.leaderstats.MaxEXP.Value = P.leaderstats.Level.Value * 59 local PositionX = script.Parent.Position.X.Offset local initX = script.Parent.Size.X.Offset while true do wait() local EXP = script.Parent.Parent.Parent.Parent.Parent.leaderstats.EXP.Value local EXPMax = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Level.Value * 59 local Pie = (EXP / EXPMax) --Missed Scale --script.Parent.Size = UDim2.new( 0, initX*Pie, 0, 30) script.Parent:TweenSize(UDim2.new(0, initX*Pie, 0, 30),"Out","Sine",0.25) end
0
Thanks. I found out why it didnt work, in line 17 I wrote "local Pie = (EXP / EXPMAX)" when it should have been "local Pie= (EXP / MaxEXP)" attackonkyojin 135 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

The script isn't working because the TweenSize command only occurs if EXP > MaxEXP (at which point EXP is reset anyway). After the first level is achieved, the script will appear to start working.

However, you are starting a new infinite loop every time EXP > MaxEXP. Instead, either take the while loop out of the "Changed" function (ex add an 'end' statement on lines 8 and 9), or else move the contents of the while loop into the function (but don't use a loop).

Ad
Log in to vote
0
Answered by 9 years ago

This may be why it is not working but I carnet test it.

This may result in a float e.g 1.3442:-

local Pie = (EXP / EXPMax) 

The offset value must be in an Integer Click Here

0
The offset is automatically converted into an integer; giving it a float will not cause an error. chess123mate 5873 — 9y

Answer this question