How do i make a gui pop up if the player level does not reach the required level

Hi so I’m using Evercyans RPG Kit and wanted to add a level not met GUI to pop up to let the player know that they cannot access the level door

here is my script:

local players = game:GetService("Players")

workspace.GameDoorHolder.LevelDoor.Head.Touched:Connect(function(hit)
	if hit then
		wait(1)
		local leaderstats = players:WaitForChild("leaderstats")
		local Level = leaderstats:WaitForChild("Level")
		if leaderstats.Level >= 5 then
	script.Parent.TeleportWarning.Background.Visible = true
	wait(5)
	script.Parent.TeleportWarning.Background.Visible = false
	end
end

Just add an else to the if statement where you check the level.

Where is this script located? In ServerScriptService?

i put the script in StarterGUI

local player = game:GetService("Players").LocalPlayer

workspace.GameDoorHolder.LevelDoor.Head.Touched:Connect(function(hit)
    if hit.Parent.Name == player.Name then
        wait(1)
        local leaderstats = player:WaitForChild("leaderstats")
		local Level = leaderstats:WaitForChild("Level")
		if Level.Value >= 5 then
		    script.Parent.TeleportWarning.Background.Visible = true
	wait(5)
	script.Parent.TeleportWarning.Background.Visible = false
		end
       end
end)

Sorry about the indentation I’m writing it on mobile.

And this script should be a local script.

should I put it in StarterGUI or ServerScriptService

For this script you can put in startergui.

Oh and I just changed it to Level.Value assuming it’s a number value or and intvalue.

It didn’t show up should I add TeleportWarning as a local

Ye copy and paste the script again I made an error and just changed the script.

local player = game:GetService("Players").LocalPlayer

workspace.GameDoorHolder.LevelDoor.Head.Touched:Connect(function(hit)
    if hit.Parent.Name == player.Name then
        wait(1)
        local leaderstats = player:WaitForChild("leaderstats")
		local Level = leaderstats:WaitForChild("Level")
		if Level.Value >= 5 then
		    script.Parent.TeleportWarning.Background.Visible = true
	wait(5)
	script.Parent.TeleportWarning.Background.Visible = false
		end
	end
end)

It still doesn’t work but is there a value for less or lower? or is it always >=

That is more than or equal to.

Here’s an alternative, you put the script I wrote below as a child of workspace.GameDoorHolder.LevelDoor.Head

script.Parent.Touched:Connect(function(hit)
    if game:GetService("Players"):findFirstChild(hit.Parent.Name) then
        wait(1)
        local Player = game:GetService("Players")[hit.Parent.Name]
        if Player:WaitForChild("leaderstats").Level.Value <= 5 then
            Player.PlayerGui.TeleportWarning.Background.Visible = true
            wait(5)
            script.Parent.TeleportWarning.Background.Visible = false
        end
    end
end)

i changed the value for the first script you send too <= and tested it and it worked thank you so much

This 1 have to be a script though not a local script

could the second one be in any script?

For the last script I made, you have to put it inside of the Directory I told you but for that script it has to be a “Script” and not a “LocalScript” since it’s not part of the player and it will look cleaner so you don’t have a clogged scripts in your startergui

1 Like