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

How to make a button invisible when having a certain amount of stats?

Asked by 2 years ago

Hello guys. I've been trying for hours to make a button invisible by having a certain amount of stats inside the "players/playername" folder when the player joins the game, but without any success. Did I do something wrong? Thanks in advance!

Here's the code:

local player = game.Players.LocalPlayer
local lock = script.Parent.lock



game.Players.PlayerAdded:Connect(function()
    if player.Powerlevel.Value >= 250 then
        lock.Visible = false
    end
end)

Sorry, I am pretty new to scripting

0
Is this under leaderstats or what is it under? Name the hierarchy. Like workspace --> Model -- > Part --> WeldConstraint for example 2Loos 168 — 2y

2 answers

Log in to vote
0
Answered by
2Loos 168
2 years ago
local player = game.Players.LocalPlayer
local lock = script.Parent.lock



game.Players.PlayerAdded:Connect(function()
    if game.Players[player.Name].Powerlevel.Value >= 250 then
        lock.Visible = false
    end
end)

Try this. I'm doing this blindly with no clue of what your hierarchy is

Ad
Log in to vote
0
Answered by 2 years ago

Try putting a local script as a child of the button you want to make invisible then put in this

local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")--Gets the leaderstats from the local player
local Powerlevel = stats:WaitForChild("Powerlevel")--Gets the powerlevel from the leaderstats

game.Players.PlayerAdded:Connect(function()
    if Powerlevel.Value >= 250 then --if the local player power level is higher or equal to 250 then make the script's parent invisible
        script.Parent.Visible = false
    end
end)

Tell me if it works!

Answer this question