I have tried to create a level system with a gui that shows what level you are at but the gui part just wont work here is the script
local player = game.Players.LocalPlayer local xp = 0 local level = 0 local xpneeded = 100 local levelsgui = script.Parent.Parent.Frame.Levels local xpgui = script.Parent.Parent.Frame.xp xpgui.Text = "xp: "..xp levelsgui.Text = "level: "..level workspace.Coin.ClickDetector.MouseClick:Connect(function() xp +=1 if xp == xpneeded then xpneeded += 100 level +=1 player.leaderstats.Levels.Value +=1 end end) xpgui.Text = "xp: "..xp levelsgui.Text = "level: "..level script.Parent.MouseButton1Click:Connect(function () script.Parent.Parent:WaitForChild("Frame").Visible = not script.Parent.Parent:WaitForChild("Frame").Visible end)
If you can help me thanks it sill be very appreciated^^
I know I left a comment but I figured I'd answer as well just to show you. While using a while true do loop like the user above me suggested would work, it isn't as simple as it could be and would slow down your game if it had a lot of scripts running. Instead what I would do is change the gui text inside of the MouseClick function that you already have set up. Currently you are only changing the GUI text once when the script runs, however if you put lines 18 and 19 inside of your function like below, it should work like you want it:
local player = game.Players.LocalPlayer local xp = 0 local level = 0 local xpneeded = 100 local levelsgui = script.Parent.Parent.Frame.Levels local xpgui = script.Parent.Parent.Frame.xp xpgui.Text = "xp: "..xp levelsgui.Text = "level: "..level workspace.Coin.ClickDetector.MouseClick:Connect(function() xp +=1 if xp == xpneeded then xpneeded += 100 level +=1 player.leaderstats.Levels.Value +=1 end xpgui.Text = "xp: "..xp levelsgui.Text = "level: "..level end) script.Parent.MouseButton1Click:Connect(function () script.Parent.Parent:WaitForChild("Frame").Visible = not script.Parent.Parent:WaitForChild("Frame").Visible end)
Hope I helped!
You need a while true do loop
the code is
local player = game.Players.LocalPlayer local xp = 0 local level = 0 local xpneeded = 100 local levelsgui = script.Parent.Parent.Frame.Levels local xpgui = script.Parent.Parent.Frame.xp xpgui.Text = "xp: "..xp levelsgui.Text = "level: "..level script.Parent.MouseButton1Click:Connect(function () script.Parent.Parent:WaitForChild("Frame").Visible = not script.Parent.Parent:WaitForChild("Frame").Visible end) workspace.Coin.ClickDetector.MouseClick:Connect(function() xp +=1 if xp == xpneeded then xpneeded += 100 level +=1 player.leaderstats.Levels.Value +=1 end end) while true do xpgui.Text = "xp: "..xp levelsgui.Text = "level: "..level wait(0.01) end