Ad
Log in to vote
0

Can exploiters take advantage of this script?

Asked by 5 days ago

I asked this question yesterday but never received a solution so I am going to ask again. I am really new to scripting and I am making a speed run game that will start the player's timer on their GUI when they touch a Part. The timer is saved as a leaderstat and I am using remote events to add to the timer. The touch event is in the player GUI and the calculations for the player's time are in the server script. Again, I am pretty new to scripting so is this a valid way of scripting my game while also preventing exploiters from tampering with their speed run times? Any help would be greatly appreciated

Local Script inside player's GUI

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("ShowTime")
local Clear = ReplicatedStorage:WaitForChild("ClearTimeran")
local Replace = ReplicatedStorage:WaitForChild("Replace")


local SpeedBrick = workspace.RunBlock
local EndBrick = workspace.EndBlock

local go = true
local db = false
SpeedBrick.Touched:Connect(function(hit)
    local startplayer = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
    if startplayer ~= nil and startplayer ==  game:GetService("Players").LocalPlayer then
        if db == false then
            db = true
            Clear:FireServer()
            repeat
                wait(0.1)
                remoteEvent:FireServer()

                ---SHOWING ON GUI---
                local player = script.Parent.Parent.Parent.Parent.Parent

                local leaderstats = player:WaitForChild("leaderstats")
                local stat = leaderstats:WaitForChild("runningtime") 
                local besttime = leaderstats:WaitForChild("time1")

                script.Parent.Text = stat.Value

                stat.Changed:Connect(function()
                    script.Parent.Text = stat.Value
                end)
                if stat.Value < besttime.Value then
                    local ColorNew = Color3.new(0.333333, 1, 0) --GREEN
                    script.Parent.TextColor3 = ColorNew
                end
                if stat.Value > besttime.Value and besttime.Value ~= 0 then
                    local ColorNew = Color3.new(1, 0, 0) --RED
                    script.Parent.TextColor3 = ColorNew
                end
                -------------------

                EndBrick.Touched:Connect(function(hit)
                    local endplayer = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
                    if endplayer ~= nil and endplayer ==  game:GetService("Players").LocalPlayer then
                        go = false
                    end
                end)
            until go == false
        end
        wait(0.5)
        db = true
    end
    --Clearing timeran and replacing leveltime
    if go == false then
        local player = script.Parent.Parent.Parent.Parent.Parent
        local leaderstats = player:WaitForChild("leaderstats")
        local stat = leaderstats:WaitForChild("runningtime")
        local leveltime = leaderstats:WaitForChild("time1")
        if stat.Value < leveltime.Value then
            Replace:FireServer(leveltime,stat)
            script.Parent.Parent.BestTimeValue.Text = stat.Value
        elseif leveltime.Value == 0 then
            Replace:FireServer(leveltime,stat)
            script.Parent.Parent.BestTimeValue.Text = stat.Value
        end
    end
end)

Server Script

local remote = game:GetService("ReplicatedStorage")
local remoteEvent = remote:WaitForChild("ShowTime")

remoteEvent.OnServerEvent:Connect(function(player)  
    player.leaderstats.runningtime.Value = player.leaderstats.runningtime.Value + 0.1
end)

Please ask me if you need any more information. Thanks so much!

0
Basically, as long as the value for the run's time doesn't touch the client you should be fine. Not too sure exactly what you mean by "add to the timer", it would probably be a better idea to have the time sent to the leaderboards be the starting time subtracted from the finish time (use os.time). Benbebop 933 — 5d
0
Ok, so what I meant by "add to the timer" was that once the player touches the part, it will enter a repeat until loop and wait(0.1). Every 0.1 seconds it fires a remote event to the server that takes their leaderstat value 'runtime' and adds 0.1 to it. It is keeping track of how long it takes them to complete the course. I hope this helps. xboxking2000 0 — 5d

1 answer

Log in to vote
0
Answered by 4 days ago
Edited 4 days ago

The answer is yes, anytime anything is calculated on the client rather than server side; it's exploitable. All calculations & hit detections must be done on the server side to avoid exploitation & lag switching & collision latency can still be messed with to achieve impossible/difficult result without actual skill.

Ad

Answer this question