I am trying to secure my remote events via the server by checking to make sure the player that fired the remote event has a certain user id. However, its not doing that properly. Here is the script:

askServer = game.ReplicatedStorage.Remotes.AskServer
kick = game.ServerStorage.Binds.KickPlayer
textService = game:GetService("TextService")
local filteredMessage
allowedToKick = {} --hidden for privacy reasons.

askServer.OnServerEvent:Connect(function(player, playerToKick, kickMessage)
	if table.find(allowedToKick, player.UserId) ~= nil then
		local success, notSuccess = pcall(function()
			filteredMessage = textService:FilterStringAsync(kickMessage, player.UserId):GetNonChatStringForBroadcastAsync()
		end)
		
		if success then
			game.Players:FindFirstChild(playerToKick):Kick(filteredMessage)
		else
			print("Error kicking")
			warn(notSuccess)
		end
	else
		player:Kick("Nice Try.")
	end
end)

kick.Event:Connect(function(player)
	if typeof(player) == "string" then
		game.Players:FindFirstChild(player):Kick("You are banned. You had your chance. Should have followed the rules.")
	else
		player:Kick("You are banned. You had your chance. Should have followed the rules.")
	end
end)

1 comment

0

Where is the script that fires