How would I make this

Does anyone know how I would make a system that makes a gui button visible when a player has a certain datastore value or leadersta value I mean like if they get 100 exp they unlock a button on their screen that becomes visible.

4 Likes

Lets say you have already a datastore that saves the value in leaderstats of the player in a value called “EXP”.
In the button you can do:

local Player = game.Players.LocalPlayer
local leaderstats = Player:WaitForChild("leaderstats")
local EXP = leaderstats:WaitForChild("EXP")
local Button = script.Parent

EXP.Changed:Connect(function()
    if EXP.Value >= 100 then
        Button.Visible = true 
    else 
        Button.Visible = false
    end
end)
4 Likes

damn lol it was that basic lol I’m very dumb

3 Likes

Haha, no problem. If this fixed it, then please mark the post as Solution. It really helps others know that this post has been solved and it would also help me out!
*It looks like this: *
image

1 Like

won’t show Buttons Idk I can send what I moded

1 Like

local Player = game.Players.LocalPlayer
local leader = Player:WaitForChild(“leaderstats”)
local Awards = leader:WaitForChild(“Awards”)
local Button = script.Parent
Button.Visible = false
Awards.Changed:Connect(function()
if Awards.Value >= 40000 then
Button.Visible = true
else
Button.Visible = false
end
end)

1 Like

Leadersats or data

local DSS = game:GetService(“DataStoreService”)
local statsDS = DSS:GetDataStore(“statsDS”)

game.Players.PlayerAdded:Connect(function(plr)
local lead = Instance.new(“Folder”)
lead.Name = “leaderstats”
lead.Parent = plr

local Wallet = Instance.new("IntValue")
Wallet.Name = "Wallet"
Wallet.Parent = lead
Wallet.Value = 55000 --(0)--

local diam = Instance.new("IntValue")
diam.Name = "Bank"
diam.Parent = lead
diam.Value = 0

local Awards = Instance.new("IntValue")
Awards.Name = "Awards"
Awards.Parent = lead
Awards.Value = 40000
2 Likes

Should probably add a line that updates the Visibility of the frame when the script starts running, otherwise, when the player change, it will only update when EXP changes

1 Like

This might be why
(minimum characters arrgggg)

1 Like

local Player = game.Players.LocalPlayer
local leader = Player:WaitForChild(“leaderstats”)
local Awards = leader:WaitForChild(“Awards”)
local Button = script.Parent
Button.Visible = false
Awards.Changed:Connect(function()
Button.Visible = true- This???
if Awards.Value >= 40000 then
else
Button.Visible = false
end
end)

1 Like

No need to make it be false … it should start that way. Make sure @ jack script is set to the correct spot and that is all you should need.

1 Like

it is preset in properties as false visible

1 Like

That wont change anything. Here is code that should work, I basically copied the if statement and pasted it outside the function, so it will run when the script starts, and not just when the value of EXP changes

local Player = game.Players.LocalPlayer
local leaderstats = Player:WaitForChild("leaderstats")
local EXP = leaderstats:WaitForChild("EXP")
local Button = script.Parent

EXP.Changed:Connect(function()
    if EXP.Value >= 100 then
        Button.Visible = true 
    else 
        Button.Visible = false
    end
end)

-- Check if the value is correct when the script runs
if EXP.Value >= 100 then
    Button.Visible = true 
else 
    Button.Visible = false
end
1 Like

You aren’t. You’re still learning.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.