Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

4 comments

2

If you're using a serverside inside the GUI, I found that that wont work; you have'ta make it a clientside. ;/

0

Was Player defined?

0

^ Yh, and what he said.

0

Player was defined.

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.