So quick rundown
Making a game that involves putting mesh parts into the workspace.
Was testing out some features when two users who I won’t name, joined and quickly spammed the remote event that was triggering the mesh parts to spawn, with the use of an exploit.
Very basic exploit, kinda embarrassing tbh, however that’s not what I’m here for.
Its been a long, long time since I’ve made any anti exploit code so I’m a little unsure of how I should go about doing this
In short: How would I go about checking the workspace to see if there are more than 50 mesh parts by the names “Brick” and “Done” and remove them all at the same time?
Any help is great, kinda tried and my collaborator is asleep so I’m the only one here to fix this rn.
local brickPart = {}
local donePart = {}
for i,v in pairs(workspace:GetDescendants()) do
if v.Name == "Brick" then
table.insert(brickPart,v)
elseif v.Name == "Done" then
table.insert(donePart,v)
end
end
if #brickPart or #donePart >= 50 then -- If parts named Brick and Done is greater than 50 then
print('50+ blocks')
end
Maybe workspace already have 50 blocks.
Other way is checking how many times a remote event is firing.
Buggy method
local repeated = {}
event.OnServerEvent:Connect(function(player)
if repeated[player] then
repeated[player] += 1
else
repeated[player] = 0
end
delay(2,function()
repeated[player] = 0
end)
if repeated[player] >= 30 then -- If player is firing remote event more than 30 times in 2 seconds then it kicks them.
player:Kick("Remote event is firing continuously.")
end
end)
or you can do the same thing using tick() With Tick
local repeated = {}
local eventTime = .5
local event = game.ReplicatedStorage.RemoteEvent
event.OnServerEvent:Connect(function(player)
local oldtick
if repeated[player] then
print(tick()-repeated[player])
if (tick()-repeated[player]) <= eventTime then -- If remote event is fired every .5 or lower then
warn('Remote event spam detected.')
end
else
repeated[player] = tick()
end
repeated[player] = tick()
end)