I want to kick the player if they click a button too many times, like “spacebar” 100 times in a row, or move them to a certain spot.
Sadly I don’t understand how to detect the change or my brain just isn’t registering what I need to do.
Local script in starterplayerscript:
local userInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
userInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
local inputType = input.UserInputType
local input = input.KeyCode
game.ReplicatedStorage.RemoteEvents.UserInputRemotes.UserInput:FireServer(input, inputType, player)
end
end)
The second script is my server script:
local replicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = replicatedStorage:WaitForChild("RemoteEvents")
local userInputEvent = Remotes:WaitForChild("UserInputRemotes")
local count = 0
userInputEvent.UserInput.OnServerEvent:Connect(function(player, input, inputType)
print("event for user input fired")
print(input)
print(inputType)
if input == input then
count = count + 1
print(count)
if count >= 10 then
player:Kick("You've been kicked to many identical attempts")
end
end
end)
My only real problem is that I can see it printing the different keycodes but how do I make it stop the count and start it again? If I make a local variable it always assigns the keycode from the localscript in the remote event to that keycode, so the server will always see them matching.