Unlocking system (gui)

Since it is a local script, you should put it in StarterGui.

(Character Limit)

level is not a valid member of Folder “Players.Ryan_Danial.leaderstats”

do you want the server know that the gui is opening?

opening, do yo meant the gui visible is true ?

1 Like

yes I want the the server know the gui is valid for the player to use

i just make a basic data system let me do some final last check

1 Like

try this out on the server,combine this with the leaderstats you gave me before:

local levelcap = 100 -- insert your own level cap here
game.Players.PlayerAdded:Connect(function(Player)
	local folderstats = Instance.new("Folder")
	folderstats.Parent = Player
	folderstats.Name = "leaderstats"
	local xp = Instance.new("IntValue",folderstats)
	xp.Name = "Exp"
	xp.Value = 0
	local Xpneed = Instance.new("IntValue",folderstats)
	Xpneed.Name = "MaxExp"
	Xpneed.Value = 100
	local level = Instance.new("IntValue",folderstats)
	level.Name = "levels"
	level.Value = 0
	game:GetService("RunService").Heartbeat:Connect(function()
		if xp.Value >= Xpneed.Value and level.Value < levelcap then 
			xp.Value -= Xpneed.Value
			Xpneed.Value += 100
			level.Value += 1
		end
		if level.Value >= 1 then
			if Player.PlayerGui:FindFirstChild("stat system") then
				Player.PlayerGui:WaitForChild("stat system"):WaitForChild("menu system"):WaitForChild("menu"):WaitForChild("co op").Visible = true
			end
		end
	end)
end)

I edited the script I made try it again.

1 Like

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.levels

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

he want the server to know that the gui is visible maybe this won’t work,try make it work with server script?

I’m not the most experienced with gui but I’m pretty sure you can’t access PlayerGui through a server script. Instead I can use a remote event to set a boolean value to true, so the server knows the gui is visible.

Create a remote event in ReplicatedStorage and call it “GuiVisibleEvent” This is so the local script and server script can communicate with each other.

You can try this code:

Local Script

local player = game.Players.LocalPlayer
local open = player.PlayerGui["stats system"]["menu system"].menu["co op"]
local level = player.leaderstats.levels
local RE = game.ReplicatedStorage.GuiVisibleEvent
level.Changed:Connect(function(value)
    if level.Value >= 1 then
        open.Visible = true
        RE:FireServer()
    end
end)

Server Script

game.Players.PlayerAdded(Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        player.GuiVisibleEvent.OnServerEvent:Connect(function(player)
            local GuiVisible = Instance.New("BooleanValue", player)
            GuiVisible.Name = "GuiVisible"
            player.GuiVisible.Value = true--Sets value to true so you know the player can see the gui
        end)
    end)
end)

you can access that playergui if the server know who it need to access
by using a remote event (on server event) you are actually accessing it through server

the script I have change a little for the gui, but when i tried to test it if the print to show if the script work or not. but not one of the print that I have set, print to the output and not only that the gui the supposed to show up in the menu is not showing. my brain really tried :woozy_face:

local levelcap = 100 -- insert your own level cap here
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 level = Instance.new("IntValue", player)
	level.Name = 'levels'
	level.Value = 0
	
	local Xpneed = Instance.new("IntValue", player)
	Xpneed.Name = "MaxExp"
	Xpneed.Value = 100
	
	game:GetService("RunService").Heartbeat:Connect(function()
		if xp.Value >= Xpneed.Value and level.Value < levelcap then 
			xp.Value -= Xpneed.Value
			print("value request")
			Xpneed.Value += 100
			level.Value += 1
		end
		if level.Value >= 1 then
			print("value reach")
			if player.PlayerGui:FindFirstChild("stat system") then
				player.PlayerGui:WaitForChild("stat system"):WaitForChild("menu system"):WaitForChild("menu"):WaitForChild("co op").Visible = true
				print("varible meet")
			end
		end
	end)

hmmmm, in my script it just work out of the box

Do you want the server to know that the player can see the gui?

1 Like

is this script put in the leaderstats script?

one on server one on the gui you need

1 Like

You can put the server script I sent you in ServerScriptService as a new script and the local script in StarterGui.

wait did you increase the exp value?

1 Like

increase value for test the script? yes, I test the script by increasing the xp value cause I don’t have a script that give xp

1 Like