So I'm making a GUI that shows some cool geeky information like their account age for example. But I've fell into yet another pit. Here's the script:
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local plrname = char.Name
local plrageraw = plr.AccountAge / 365
local plrid = plr.UserId
local plragebox = script.Parent.UserAge
local plridbox = script.Parent.UserID
local plrsessionbox = script.Parent.UserSessionTime
function PlayerAge()
local updated = 0
local us = "Info has updated"
local ss = "during this session."
while true do
updated = updated + 1
print("User Info updated")
if updated == 1 then
print(us.." one time "..ss)
elseif updated == 2 then
print(us.." two times "..ss)
elseif updated == 3 then
print(us.." three times "..ss)
elseif updated == 4 then
print(us.." four times "..ss)
elseif updated == 5 then
print(us.." five times "..ss)
elseif updated == 6 then
print(us.." six times "..ss)
elseif updated == 7 then
print(us.." seven times "..ss)
elseif updated == 8 then
print(us.." eight times "..ss)
elseif updated == 9 then
print(us.." nine times "..ss)
elseif updated == 10 then
print(us.." ten times "..ss)
elseif updated > 10 then
print(us.." "..updated.." times "..ss)
end
local plrageraw1 = plrageraw * 1000
local plrageraw2 = math.ceil(plrageraw1)
local plragefixed = plrageraw2 / 1000
plragebox.Text = ("Account Age: "..plragefixed.." years")
plridbox.Text = ("User ID: "..plrid)
warn("User Info will update in 5 minutes")
wait(300)
end
end
function PlayerSession()
local sec = 0
local min = 0
local hr = 0
while true do
sec = sec + 1
if sec >= 60 then
sec = 0
min = 1
elseif min >= 60 then
sec = 0
min = 0
hr = 1
end
plrsessionbox.Text = ("User Session Time: "..hr.."h "..min.."m "..sec.."s")
wait(1)
end
end
PlayerAge()
PlayerSession()
So I can't find out what's wrong with the "Session" part. There's no error in the output and I've looked over it and it appears to be normal. The other two parts of the GUI works just fine. I might be missing something but like I said, it appears to be normal. I am a bit new at coding in Lua. I've tried putting the local variables [sec, min, hr] outside the function, but I expected it not to work and of course, it didn't work.
Thanks in advance! :)

1 comment
You have while true do in your PlayerAge() function so your PlayerSession() was never activated.