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

How do I make a character levitate in the direction they are facing?

Asked by 6 years ago
Edited 6 years ago

Hello! So, I created a tool that allows a player to levitate upwards very slowly, for a singleplayer FilteringEnabled = false game. The problem is, it only lets the character go upwards. How do I make the character go forwards when W is pressed? The following is in a localscript in a tool.

local Character = game.Players.LocalPlayer.character
local TorPos = Character.HumanoidRootPart.Position
local Player = game.Players.LocalPlayer
local HumRoot = Character.HumanoidRootPart
local Mouse = Player:GetMouse()
local LevHeight = Vector3.new(0,.5,0)


local Levitating = false

function levitate()
    if Levitating == false then 
        Levitating = true

        local BodyPos = Instance.new("BodyPosition")
        BodyPos.Parent = Character.HumanoidRootPart

        while Levitating == true do

                BodyPos.Position = HumRoot.Position + LevHeight
                wait(.01)

            end
            BodyPos:Destroy()
        end

end



function SetLevFalse()
    Levitating = false
end

function PrintPos()
    print(HumRoot.Position)
end


Mouse.Button1Down:connect(levitate)
Mouse.Button1Up:connect(SetLevFalse)
Mouse.Button2Down:connect(PrintPos)

Answer this question