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

What is wrong with this code it doesn't let me see the button???

Asked by 8 years ago
Edited 8 years ago
1local player = game.Players.LocalPlayer
2local level = player.leaderstats.Level
3 
4if level.Value >= 1
5 then player.PlayerGui.ScreenGui.TextButton.Visible = true
6 else player.PlayerGui.ScreenGui.TextButton.Visible = false
7end

this code is supposed to let the player see the button only after he reaches LVL.1 but it doesn't show it even after he reaches LVL.1

2 answers

Log in to vote
0
Answered by 8 years ago

Try this:


1local player = game.Players.LocalPlayer
2local level = player:WaitForChild("leaderstats"):WaitForChild("Level")
3while true do wait()
4if level.Value >= 1
5 then player.PlayerGui.ScreenGui.TextButton.Visible = true
6 else player.PlayerGui.ScreenGui.TextButton.Visible = false
7end
8end
0
THANK YOU MAN Vlad_DraculaTV -2 — 8y
Ad
Log in to vote
0
Answered by
Zrxiis 26
8 years ago
Edited 8 years ago
01--// I believe it would look more along the lines of this
02local player = game.Players.LocalPlayer
03local level = player.leaderstats.level
04level.Changed:connect(function()
05    if level.Value >= 1 then
06        player.PlayerGui.ScreenGui.TextButton.Visible = true
07    elseif level.Value < 1 then
08        player.PlayerGui.ScreenGui.Textbutton.Visible = false
09    end
10end

Answer this question