Whitelist script not working

i also don’t know what the problems are cause i don’t get any errors that’s why it is so weard or something cause the ui is just not showing up but srr for spending your time i’m just gonna use the old script the script with the ui is not working!

cause i don’t really want to spend your time right now if it’s not working i will just use the old scipt and ty for all the help you did try to do!

That’s not what I meant. What I meant is that I’d like for you to have updated me on where you’re at right now with your code and what the problem is. That meaning, posting the code you currently have, a picture of where the script is in your explorer (would be helpful) and what the problem is.

If you’ve found something in this thread that works though, then that’s great.

The scipt is in the ServerScriptService
And the UI is in the StarterGui

you can se it on the picture right here

And also i wanted to make a UI to come up so that players that are not whitelisted that they can’t se the actual game cause it will spoil all the new updates that are coming cause all the updates will be showing up in that game to test out.

cause you can se the game at the background when getting kicked that’s also why it will be a spoiler

Uh i tested the script and it’s not even kicking me and i’m not in the whitelist bruh so the script is broken but it’s not showing errors

but ye nvm i’m just gonna use the old script

BRUH I FIXED IT this was so easy to fix wow i didn’t know i am so dumb

local WhiteList = {} --User id here

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(chr)
		if table.find(WhiteList, plr.UserId) then
			print("Owner did join the game")
		else
			local UI = game.StarterGui.ServerIsLocked
			UI.NoSpoilerFrame.Visible = true
			plr:Kick("You are not allowed to join the game only game devs can join the game this game is in test proces")
		end
	end)
end)
1 Like

Please try and keep extra remarks in as little posts as possible. You can edit your previous posts if you have a bit of extra things to say. This is a forum not an instant message board like Discord.

Anyhow: editing Guis with server scripts isn’t typically something I recommend but I just made a barebones repro using similar code and it worked as expected for me, so there’s that.

local Players = game:GetService("Players")

local WHITELIST = {}

local ServerLocked = script.ServerLocked

local function playerAdded(player)
	if ServerLocked.Value == true and not table.find(WHITELIST, player.UserId) then
		player:WaitForChild("PlayerGui"):WaitForChild("Boozled").Enabled = true
	end
end

Players.PlayerAdded:Connect(playerAdded)
for _, player in ipairs(Players:GetPlayers()) do
	playerAdded(player)
end

That being said, I discovered the cause of your issue after looking more closely at your code. What’s happening is a bad case of indenting. What your code is actually doing is this:

if serverlocked then
    if whitelisted then
        do nothing
    end
else
    server is locked, kick
end

So I’m pretty sure you just have your whitelist in the wrong place or you aren’t reading your code correctly here. I’ve compounded the whitelist and server lock check in one if statement to make it more apparent when a kick check should happen. Your new code is better than the old one (you shouldn’t even be using CharacterAdded for a whitelist script), you just had a case of bad indenting and couldn’t read your code properly.

oh nvm i’l dumb it’s just the loading screen in my script i am trying your script now

Your script is working ty for helping and maybe next time i will ask someone for there discord.

i am also still learning to script i am not a pro or something in it right now.

This is the test server so if you join you will get kicked i will not get kicked.