Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

This function won't trigger when a player joins? Please Help.

wait(1)
game.Players.PlayerAdded:Connect(function(plr)
	wait(1)
	local banfolder = game.Lighting:FindFirstChild("ServerBans")
	if banfolder:FindFirstChild(plr.Name) then
		
	plr:Kick("Unable to connect to server for reason: You have been banned.")
	print("[AdminGUI Plugin] ".. plr.Name .. " Attempted to join the server but failed with the error message: Player Banned.")
	else
		print("[AdminGui Plugin] "..plr.Name.." passed the ban check.")
	end	
end)

This is not the only thing in the script. This is just a part and every thing else runs but this.

7 comments

0

Also this is the top of the script.

0

Have you tried game.Lighting:WaitForChild(“ServerBans”)?

0

Also would it not make more sense to store something like this is ReplicatedStorage rather than lighting

0

Do there's any errors in the output?

0

ReplicatedStorage is when everyone can access it, a hacker maybe can delete some banlists and pass by the check. You should put it in the ServerStorage since only the server can access it and players can't which essentially creates a secure place to store things that shouldn't be in the hands of a player.

0

Also the reason why a lot of people are saying events don't work is because of a if statement that is blocking what they are supposed to do. In the event you are checking if the player joined is in the ban list and will only execute code if so. I assume your testing and you don't have the usernames in the ban list and that's why it looks like it "doesn't execute".

0

123nabilben123, I am not testing. I used to have it in ServerStorage I was seeing is Lighting made a diffrence. Txeer, I was thinking of doing that I will check if that makes a diffrence.

1 answer

I had the code in a GUI that was in StarterGui. The issue with this is that a script in a Gui will not do very many tasks as anything in StarterGui is cloned to the player gui folder which will not execute scripts that kick others.

This discussion is preserved as it was. New answers, comments, and votes are closed.