Unlocking system (gui)

hello I trying to make a unlocking system that when the player reach the amount of level that will unlock the gui button, but I don’t know how would the script go about. this is the script that i tried to made by my self.

local players = game:GetService("Players")

local player = players.LocalPlayer
local gui = player.PlayerGui["stats system"]["menu system"].menu["co op system"]

local open = player.PlayerGui["stats system"]["menu system"].menu["co op"]
local xp = Instance.new("IntValue", player)
xp.Name = 'Exp'
xp.Value = 0 
local level = Instance.new("IntValue", player)
level.Name = 'level'
level.Value = 0
local leaderstats = game.Players:WaitForChild('leaderstats')

game.Players.PlayerAdded:Connect(function(player)
	while level.Value >= 1 do --value required
		player.PlayerGui["stats system"]["menu system"].menu["co op"].Visible = true 
		if player.PlayerGui["stats system"]["menu system"].menu["co op"].visbile == false then
			repeat until -- repeat until the gui visible = true
			player.PlayerGui["stats system"]["menu system"].menu["co op"].Visible == true
		end
	end
end)

Does your script work or is there an error?

the script doesn’t work it just a example for what I have tried to script for the unlocking system

Try this:

local players = game:GetService("Players")

local player = players.LocalPlayer
local gui = player.PlayerGui["stats system"]["menu system"].menu["co op system"]

local open = player.PlayerGui["stats system"]["menu system"].menu["co op"]
local xp = Instance.new("IntValue", player)
xp.Name = 'Exp'
xp.Value = 0 
local level = Instance.new("IntValue", player)
level.Name = 'level'
level.Value = 0
local leaderstats = game.Players:WaitForChild('leaderstats')

game.Players.PlayerAdded:Connect(function(player)
	level.Changed:Connect(function(value)
       if level.Value >= 1 then --value required then
	    	player.PlayerGui["stats system"]["menu system"].menu["co op"].Visible = true 
		end
	end
end)
1 Like

the script that you have suggest is not working

I put “do” instead of “then” I will edit the script right now.
Try copying and pasting it again, I fixed it.

I have already change it and still not working

Are there any errors in the output?

there’s is no error with the script

do you initalized your leaderstats folder?

game.Players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("Folder",player)
	stats.Name = "leaderstats"
		local xp = Instance.new("IntValue", player)
		xp.Name = 'Exp'
	    xp.Value = 0
	
	    local maxExp = Instance.new("IntValue", player)
	    maxExp.Name = "MaxExp"
	    maxExp.Value = 100

		local level = Instance.new("IntValue", player)
		level.Name = 'levels'
		level.Value = 0
1 Like

can you check the output for error and send it here pls

there is no error, it just the script doesn’t function

1 Like

try this:

game.Players.PlayerAdded:Connect(function(player)
	local gui = player.PlayerGui:WaitForChild("stats system"):WaitForChild("menu system"):WaitForChild("menu"):WaitForChild("co op system")
	local opens = player.PlayerGui:WaitForChild("stats system"):WaitForChild("menu system"):WaitForChild("menu"):WaitForChild("co op")
	local xp = Instance.new("IntValue", player)
	xp.Name = 'Exp'
	xp.Value = 0 
	local level = Instance.new("IntValue", player)
	level.Name = 'level'
	level.Value = 0
	local leaderstats = game.Players:WaitForChild('leaderstats')
	level.Changed:Connect(function(value)
		if level.Value >= 1 then --value required then
			opens.Visible = true 
		end
	end)
end)

the script doesn’t work. the script that i show cast is to show my work on trying to make the unlocking system.

Is this a server script or local script?

the script is in the server script service

my objective is to know how to make the unlocking system so I ask help to make the unlocking script cause I don’t really know how to make one

Try this in a local script

local player = game.Players.LocalPlayer
local open = player.PlayerGui["stats system"]["menu system"].menu["co op"]
local level = player.leaderstats.level

level.Changed:Connect(function(value)
    if level.Value >= 1 then
        open.Visible = true
    end
end)

where shot I put the local script