Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to prevent players from exploiting in game mechanics?

so umm my game tracks where the player is by they touching parts and it's shaped like a circle and every time they hit the finishing line their 'Lap' got increased by one. But they will just run back to the number 45 part then go to the finishing line and get it increased. My small brain can't think of a way that will work all the time

--part of the script
			elseif val == 46 then
				local l = RE[name].Lap
				if v + 1 == val or v == val then
					if not iGB then
						local y = Instance.new("IntValue",game.ReplicatedStorage[name])
						a:Destroy()
						y.Value = val
						y.Name = 'P'
						local y = Instance.new("IntValue",game.ReplicatedStorage[name])
						y.Value = l.Value + 1
						y.Name = 'Lap'
						l:Destroy()
					else
						local y = Instance.new("IntValue",game.ReplicatedStorage[name])
						a:Destroy()
						y.Value = val
						y.Name = 'P'
					end
				elseif v == 1 or v == 0 then
					local y = Instance.new("IntValue",game.ReplicatedStorage[name])
					a:Destroy()
					y.Value = val
					y.Name = 'P'
					RE.clientEventReciever:FireClient(game.Players[name],
'wrongWay')
				else
					print(v,val)
					game:GetService'Players'[name]:Kick('Lagging too much or suspect of hacking '..val)
				end
			end

1 answer

Checkpoint segments

Thanks Nintendo

Fortunately, Mario Kart worked this one out ages ago. You use checkpoints placed through the track, numbered 1 to n, with n being how many checkpoints you're using (including the start line, which can be checkpoint 1).

Each time they pass a checkpoint, you check if their (current_checkpoint + 1) % n is the same as the checkpoint number they passed. If it is, then update their checkpoint number. If it's not, then they're going the wrong way around.

Simples.

This discussion is preserved as it was. New answers, comments, and votes are closed.