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

I have this fly script but it changes speed with graphics how to fix???

Asked by 4 years ago
Edited 4 years ago

So heres the script

local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")

local myPlayer = game.Players.LocalPlayer
local myChar = myPlayer.Character
local myHRP = myChar:WaitForChild("HumanoidRootPart")
local camera = game.Workspace.CurrentCamera

local flying = false
local speed = 0.5


local bp = Instance.new("BodyPosition", myHRP)
bp.MaxForce = Vector3.new()
bp.D = 10
bp.P = 10000

local bg = Instance.new("BodyGyro", myHRP)
bg.MaxTorque = Vector3.new()
bg.D = 10

function fly()
    flying = true
    bp.MaxForce = Vector3.new(400000,400000,400000)
    bg.MaxTorque = Vector3.new(400000,400000,400000)
    while flying do
        rs.RenderStepped:wait()
        bp.Position = myHRP.Position +((myHRP.Position - camera.CFrame.p).unit * speed)
        bg.CFrame = CFrame.new(camera.CFrame.p, myHRP.Position)
    end
end

function endFlying()
    bp.MaxForce = Vector3.new()
    bg.MaxTorque = Vector3.new()
    flying = false
end

uis.InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.Space then
        if not flying then
            fly()
        else
            endFlying()
        end
    end

this is what it dose https://gyazo.com/70dca5942ee30da4b5135ed2942cf824

1 answer

Log in to vote
0
Answered by
Gojinhan 353 Moderation Voter
4 years ago

Stuff like RenderStepped and Heartbeat depend on your framerate, meaning the lower it is, the slower that will fire. here's an example:

https://gyazo.com/6c3537e0a9b7fb2b67dedaeb545cfb5e

Notice how my render and heartbeat are tied to my current fps / performance. Whereas physics stay capped at 60. I would fly suuuuper fast with that script. I'd recommend maybe trying wait() ? I'm not that experienced with run service so i actually dont know but just a suggestion and some info

0
Omg thanks so much ill try it rn! Deinonychusaurus 21 — 4y
0
it worked btw Deinonychusaurus 21 — 4y
0
k Gojinhan 353 — 4y
Ad

Answer this question