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

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

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

1 comment

0

Is this under leaderstats or what is it under? Name the hierarchy. Like workspace --> Model -- > Part --> WeldConstraint for example

2 answers

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

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!

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