Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to prevent players from exploiting in game mechanics?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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.

Ad

Answer this question