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

Im trying to make this a updating level script, it does not update, everything is defined properly?

this is my script


local plr = game.Players.LocalPlayer
print("player defined")
local stats = plr:WaitForChild("leaderstats")
print("Leaderstats Loaded")
local function UpdateTextLabel()
	
	script.Parent.Text = "Level: "..stats.Level.Value.." XP: "..stats.Exp.Value.." / "..stats.MaxExp.Value
end
print("Function loaded")
print(script.Parent.Text)
local level = stats.Level
local MaxExp = stats.MaxExp
local Exp = stats.Exp
print("leaderstats defined")

level:GetPropertyChangedSignal("Value"):Connect(UpdateTextLabel())

MaxExp:GetPropertyChangedSignal("Value"):Connect(UpdateTextLabel())

Exp:GetPropertyChangedSignal("Value"):Connect(UpdateTextLabel())

im trying to make a level up gui but it is not updating, any suggestions or tips to make it work? thanks

1 answer

Hello there.


The problem is that you called the function while connecting it to a function. To fix this, remove the "()" after the function's name.


Here's your fixed script:

local plr = game.Players.LocalPlayer
print("player defined")
local stats = plr:WaitForChild("leaderstats")
print("Leaderstats Loaded")

local function UpdateTextLabel()
	script.Parent.Text = "Level: "..stats.Level.Value.." XP: "..stats.Exp.Value.." / "..stats.MaxExp.Value
end

print("Function loaded")
print(script.Parent.Text)
local level = stats.Level
local MaxExp = stats.MaxExp
local Exp = stats.Exp
print("leaderstats defined")


level:GetPropertyChangedSignal("Value"):Connect(UpdateTextLabel)

MaxExp:GetPropertyChangedSignal("Value"):Connect(UpdateTextLabel)

Exp:GetPropertyChangedSignal("Value"):Connect(UpdateTextLabel)

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