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

Why Does This GUI Script Not Work Until I Reset?

Asked by
8391ice 91
9 years ago

The script I have written below is supposed to create an XP bar for the player that automatically updates as the player's XP changes. However, the XP bar does not update unless my player resets; when it respawns, the bar then updates. Is there anything about my script that could be causing this?

001Bar1 = script.Parent.Bar1
002    PosX1 = Bar1.Position.X.Offset
003    SizeX1 = Bar1.Size.X.Offset
004Bar2 = script.Parent.Bar2
005    PosY2 = Bar2.Position.Y.Offset
006    SizeY2 = Bar2.Size.Y.Offset
007Bar3 = script.Parent.Bar3
008    PosX3 = Bar3.Position.X.Offset
009    SizeX3 = Bar3.Size.X.Offset
010Bar4 = script.Parent.Bar4
011    PosY4 = Bar4.Position.Y.Offset
012    SizeY4 = Bar4.Size.Y.Offset
013Bar5 = script.Parent.Bar5
014    PosX5 = Bar5.Position.X.Offset
015    SizeX5 = Bar5.Size.X.Offset
View all 116 lines...
0
Wow, add some loops, this is getting hilarious. Link150 1355 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago
001Bar1 = script.Parent:WaitForChild("Bar1")
002    PosX1 = Bar1.Position.X.Offset
003    SizeX1 = Bar1.Size.X.Offset
004Bar2 = script.Parent:WaitForChild("Bar2")
005    PosY2 = Bar2.Position.Y.Offset
006    SizeY2 = Bar2.Size.Y.Offset
007Bar3 = script.Parent:WaitForChild("Bar3")
008    PosX3 = Bar3.Position.X.Offset
009    SizeX3 = Bar3.Size.X.Offset
010Bar4 = script.Parent:WaitForChild("Bar4")
011    PosY4 = Bar4.Position.Y.Offset
012    SizeY4 = Bar4.Size.Y.Offset
013Bar5 = script.Parent:WaitForChild("Bar5")
014    PosX5 = Bar5.Position.X.Offset
015    SizeX5 = Bar5.Size.X.Offset
View all 116 lines...

Try this, I added [:WaitForChild("")] so when the player loads the script doesn't start without loading the items. Hope this works! I probably didn't explain this properly, so I apologize for that.

0
I am afraid that the WaitForChild function did not work; I thank you for attempting to help, though! I actually thought this might have worked... 8391ice 91 — 9y
Ad

Answer this question