I see some scripts that use deltaTime and in an example I see, it is the returned parameter of Stepped event. The script uses deltaTime to multiply by a player’s humanoidrootpart velocity, I want to understand what multiplying velocity by time gives and what ‘delta’ means in deltaTime?
local leeway = 2 -- How many studs of leeway can the player have before they are stopped? Low values = more rubber banding during lag! local player = aPlayer local RunService = game:GetService("RunService") local lastPosition RunService.Stepped:Connect(function(deltaTime) local character = player.Character local humanoid = character:FindFirstChildOfClass("Humanoid") if character and character.PrimaryPart and humanoid then local maxSpeed = math.max(humanoid.WalkSpeed, humanoid.JumpPower) + leeway character.PrimaryPart.Velocity = character.PrimaryPart.Velocity.Unit * (math.min(maxSpeed, character.PrimaryPart.Velocity.Magnitude)) -- Limit their velocity! local currentPosition = character:GetPrimaryPartCFrame() if lastPosition then local deltaPosition = currentPosition.p-lastPosition.p if deltaPosition > character.PrimaryPart.Velocity*deltaTime + leeway then -- Check if they are moving faster than their velocity! character:SetPrimaryPartCFrame(lastPosition) -- Reset their position! end end lastPosition = currentPosition else lastPosition = nil end end)
Note: This is not my script and it is meant to stop flying, an anti-exploit script.