I am unsure if this is an issue on my side or if it’s a Roblox bug so I decided to post it in the scripting support category.
What do you want to achieve? Keep it simple and clear!
I want that when a player who is not in the group or is above a certain rank gets kicked.
What is the issue? Include screenshots / videos if possible!
In the output it says that I got kicked but the kick-GUI doesn’t show up and I can still interact with things like in-game GUIs. Sometimes the in-game GUI doesn’t load at all and my camera just freezes.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried kicking the player from a localscript instead of a serverscript but it did not work. I also scrolled through a few posts in the devforum but I couldn’t really find a post related to this.
My code:
game.Players.PlayerAdded:Connect(function(player)
if player:GetRankInGroup(groupId) >= rank or player:GetRankInGroup(groupId) == 0 then
player:Kick("Access Denied.")
end
end)
If your game is owned by a group you don’t need to kick someone from the game to achieve this. When you publish it just tick “Group Members Only” for who can play.
No, I am testing it with my main account. (should still kick me since I am above the maximum rank)
Also, no idea if that info is necessary but I am play-testing in studio. Not sure if that could have something to do with that even though I doubt it since it has worked in other games before.
When ensuring people do not join due to other things such as not meeting age requirements, I have a workaround. You would disable the Players.CharacterAutoLoads property and Player.LoadCharacter() if they meet the requirements.
local players = game:GetService("Players");
players.CharacterAutoLoads = false;
players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local humanoid = c:WaitForChild("Humanoid");
if humanoid then
humanoid.Died:Connect(function()
task.wait(players.RespawnTime)
p:LoadCharacter()
end)
end
end)
local groupId = 0; local rank = 1;
local statements = (p:GetRankInGroup(groupId) >= rank)
if statements == true then
p:LoadCharacter()
else p:Kick("You have been kicked for not meeting the requirements set forth by the experience's developer!") end
end)
game.Players.PlayerAdded:Connect(function(player)
print(player:GetRankInGroup(groupId))
print(rank)
if player:GetRankInGroup(groupId) >= rank or player:GetRankInGroup(groupId) == 0 then
player:Kick("Access Denied.")
end
end)
Interesting, it worked in a live game. What I am confused about is why it suddenly doesn’t work on a local game because I always play-test in studio and it did work before. Could it eventually be some kind of engine “bug” because according to the output I did get kicked, it’s just that I could still interact with in-game GUIs and the normal Roblox kick-GUI didn’t pop up.
Possibly. I remember the Kick UI popping up as well — regardless of whether it was in studio or a live game. Maybe it’s just an undocumented intentional change… who knows