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

Gui Not tweening when Player Gets EXP, How to fix?

Asked by
Jirozu 71
7 years ago

Just like the title says, once the Player Gets EXP, The Gui Is Susspose to tween, but for some reason, The Player Gets EXP, But the gui does not tween, How can I fix this?

while wait() do

    local XP = Player.Data.StrengthEXP.Value
    local MaxXP = Player.Data.Strength.Value*150

    local math = ( XP / MaxXP )

    script.Parent.Parent:TweenSize(UDim2.new(math,0,1,0),"Out","Quad",.25)
end

And Also, the game is filtering enabled, so i dont need to F.E this, since it's Happening on the Players Screen Only.

2
If you're using a serverside inside the GUI, I found that that wont work; you have'ta make it a clientside. ;/ TheeDeathCaster 2368 — 7y
0
Was `Player` defined? Goulstem 8144 — 7y
0
^ Yh, and what he said. TheeDeathCaster 2368 — 7y
0
Player was defined. Jirozu 71 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

A few things are wrong with your code. First of all you are using a loop, this is costly on the performance and it would be way better if you had a .Changed function refresh the bar. Also, I am assuming this is your whole script, you need to wait for the stats to load in, or else it will not work in a real game. THE MAIN PROBLEM I believe is that you are using the variable named "math" which you shouldn't do, when you type it in in script editor it turns blue, that means it has a use that does something else and you can not name it math, or else it will get confused. This is what your script should look like

local Player = game.Players.LocalPlayer
local str = Player:WaitForChild("Data"):WaitForChild("Strength")
local xp = Player:WaitForChild("Data"):WaitForChild("StrengthEXP")

function refresh()
    local maxExp = str.Value*150
    local x = x.pValue/maxExp
    script.Parent.Parent:TweenSize(UDim2.new(x,0,1,0),"Out","Quad",.25)
end
refresh()
str.Changed:connect(refresh)
xp.Changed:connect(refresh)

Ad

Answer this question