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
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)
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)
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)
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