Slocking System Issue

Hello, I am currently working on a slocking system. The system works with splits and will work like If the Player will get a Higher Rank than the “Minimum Rank To Slock” then it will fire a UI for all Clients with a little notification. But they shouldn’t be able to slock for higher ranks than they are, so even if I try locking for a higher rank it is firing the RemoteEvent and slocking the server. If you know a way how to help me then feel free to post a comment.

local GroupId = 12345
local MinimumRankToSlock = 11
local SetSlock = 0
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("slock")

game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		local split = Message:split(" ")
		if split[1] == "!slock" then
			if Player:GetRankInGroup(GroupId) >= MinimumRankToSlock then
				if split[2] <= Player:GetRankInGroup(GroupId) or split[2] == Player:GetRankInGroup(GroupId) then
					SetSlock = split[2]
					RemoteEvent:FireAllClients(split[2])
				end
			end
		end
	end)
	if Player:GetRankInGroup(GroupId) <= SetSlock then
		Player:Kick("This server is locked!")
	end
end)
2 Likes

What seems to be the issue? Only things I can see:

if split[2] <= Player:GetRankInGroup(GroupId) or split[2] == Player:GetRankInGroup(GroupId) then -- you dont need the 2nd statement since its already a less than or equal to

if Player:GetRankInGroup(GroupId) <= SetSlock then --im pretty sure you would just want this as an less than (<) since it shouldn't kick the members that are the same rank as the person that slocked the server

Also you only need to make the player.chatted connection if they’re high ranked enough.

2 Likes

Nevermind, I used toNumber() to convert the string to a number! :slight_smile:

1 Like