I’ve made a dash and i need to delay loop but its fps based , i’ve tried everything but nothing works…
here’s code:
local Velocity = Instance.new("BodyVelocity", Character.PrimaryPart)
Velocity.MaxForce = Vector3.new(1000000, 0, 1000000)
for i = 85, 16, -1 do
if Direction == "Back" then
Velocity.Velocity = Character.PrimaryPart.CFrame.LookVector * -i
elseif Direction == "Right" then
Velocity.Velocity = Character.PrimaryPart.CFrame.RightVector * i
elseif Direction == "Left" then
Velocity.Velocity = Character.PrimaryPart.CFrame.RightVector * -i
end
wait (0.007)
end
Velocity:Destroy()
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
wait(5)
local Direction = "Back"
local Velocity = Instance.new("BodyVelocity", Character.PrimaryPart)
Velocity.MaxForce = Vector3.new(1000000, 0, 1000000)
for i = 85, 16, -1 do
if Direction == "Back" then
Velocity.Velocity = Character.PrimaryPart.CFrame.LookVector * -i
elseif Direction == "Right" then
Velocity.Velocity = Character.PrimaryPart.CFrame.RightVector * i
elseif Direction == "Left" then
Velocity.Velocity = Character.PrimaryPart.CFrame.RightVector * -i
end
print(i, Direction, Velocity.Velocity)
wait (0.007)
end
Velocity:Destroy()
end)
end)
Wait has the minimum limit of 0.03 seconds btw. If put any lower or no value at all, it will use 0.03.
Why would you even need a value so negligible, just use task.wait 1/60, you’re not able to go under it anyways. However there is one other thing you could try though, you could use RunService.Hearbeat:Wait() I’d say this is what you’re looking for. Ask me if you have any issues.
This dash gets slowed overtime with the use of the RunService.Heartbeat function, Here is some code for a dash that gets slowed overtime and doesnt depend on FPS:
-- [[ Settings ]] --
local Dash_Speed = 100; -- Change this to your liking
local Dash_Duration = 0.7; -- Change this to your liking
local Dash_Range = 0.15;
-- [[ Variables ]] --
local Lifetime = 0.15;
local LookVector = HumanoidRootPart.CFrame.LookVector; -- Change this
local BV = Instance.new'BodyVelocity';
BV.MaxForce = Vector3.new(50000, 0, 50000);
BV.Velocity = LookVector * Dash_Speed;
Debris:AddItem(BV, Dash_Duration);
task.delay(Dash_Duration - Lifetime, function()
local Con;
Con = RunService.Heartbeat:Connect(function(DT)
Lifetime -= DT;
if BV == nil or BV and BV.Parent == nil then Con:Disconnect(); Con = nil; end
if Lifetime <= 0 and Con ~= nil then Con:Disconnect(); Con = nil; end
local Decrease_Rate = 0.15; -- Adjust to your liking
local Velocity = (Lifetime * Dash_Speed) / Decrease_Rate;
Velocity = math.clamp(Velocity, 0, Velocity);
BV.Velocity = Velocity;
end)
end)
This still depends on your fps or tps, If the player ever freezes their frames for extended times, force is applied and physically simulated also based on deltaTime
If you want something to consistently complete the same result, you need to define a start and end position
the clip that was sent does the same thing that my script does, theres no need for further stuff in my opinion, thats what he asked for, also it does support fps??