Hackers destroying game

I’ve recently just realeased a simulator and hackers are joining and using teleport scripts to instanmtly get all the food

I have food that when touched, you get rewarded. This is all handled on the server. Deleted a lot of the code to protect it. However, exploiters are able to ‘collect’ all the food, but the food stays on everyones screens, but when they go to collect it themselves, it destroys, but they dont get given anything for it. I’ve tried to introduce a debounce, but that doesnt work

NewFood.PrimaryPart.Touched:Connect(function(hit)
		local Character = hit.Parent
		if not Character then return end
		
		local Player = Players:GetPlayerFromCharacter(Character)
		if not Player then return end
		
		if table.find(self.FoodCollected, Player) then return end
		
		table.insert(self.FoodCollected, Player)
		-- give points
		NewFood:Destroy()
		
		task.delay(WAIT_TIME, function()			
			table.remove(self.FoodCollected, table.find(self.FoodCollected, Player))
		end)
	end)

You can monitor the players position over time on the server. This can be done by monitoring their humanoid walk direction and/or the character velocity. If their position in the next frame is not anywhere near the position they teleport to, don’t let them collect the food. You might also want to add a method of monitoring their speed.

1 Like

Could you explain what exactly they’re doing? You said they collect all the food but the food still remains on other players screen and the exploiter does not gain any rewards. Are you sure they aren’t just destroying/collecting the food on the client and just pretending they got it to trick/annoy you?

Note, you should add a magnitude check to verify that the player is within a certain stud threshold in order to pick up the food. As for the click tp (assuming this is the exploit they are using), you should do what BuilderBob suggested and monitor their position every so often. If you see it jump a large gap, then simply kick them. I wouldn’t recommend insta banning players that trigger this method as those who are super laggy will also seem like they teleported a large distance.

If you didnt try to move the part everytime. Then save the parts position and when the player touches. Check if the part position is the same with the position you saved

Generate different “food items” per player so they don’t compete over them.

Hackers can get in from free models, or from plugins injecting backdoors into your script. You should check all of the scripts (Try scrolling far to the right because code may be hidden there) and make sure you check EVERYTHING inside any free models used. Hackers could get you in trouble or banned.

Whenever a BasePart instance has its “.Touched” event connected to some callback function a “TouchTransmitter” instance is automatically created and parented to the BasePart. Exploits can fire all of these “TouchTransmitter” instances at once (what informs the server that a .Touched event has been fired).

A suggestion to the thread’s creator, you could handle all of these “.Touched” events from within a single server script and then whenever a player triggers one of these events, record the time, then if that same player triggers another event within a short time period (which would indicate that they are exploiting) you can simply kick/ban them accordingly.

Thank you for the information! I will give that a shot.

Question though. I created an anti teleport script that basically gives a player an attribute when they teleport, preventing them from getting food if theyve teleported. This works when a player teleports to sell/upgrade (legit) but actual exploiters never get given this attribute?

RunService.Heartbeat:Connect(function()
		for _, player in pairs(game.Players:GetPlayers()) do
			--if OwnsGamePass(player, "x2 Speed") or OwnsGamePass(player, "Hoverboard") then continue end
			
			local Character = player.Character
			if not Character then continue end
			
			if not self.Positions[player] then
				self.Positions[player] = Character:GetPivot()
			end
			
			local Distance = (Character:GetPivot().Position - self.Positions[player].Position).Magnitude
			
			if Distance > 10 then -- TODO Need to check if they were teleporting legit				
				player:SetAttribute("Teleported", true)
				
				task.delay(5, function()
					player:SetAttribute("Teleported", false)
				end)
				
				--return
			end
			
			self.Positions[player] = Character:GetPivot()
		end
	end)

Even tho the teleporters were 100% teleporting further that 10 studs each time.

EDIT
I got this now. Unsure how to calculate a good wait time though, without punishing actual players

if self.FoodCollected[Player] + WAIT_TIME > os.time() then
			print("❌" .. Player.Name, "is possibly an exploiter!")
			
			self.FoodCollected[Player] = os.time()
			
			return
		end
		
		self.FoodCollected[Player] = os.time()