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!
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.