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

How do I change the speed of this snowboard? (edit)

Asked by 5 years ago
Edited 5 years ago

I looked everywhere in the script to see what affects the speed but nothing worked

local Board = script.Parent
local Controller
local Gyro
local CoastingAnim
local KickAnim
local LeftAnim
local RightAnim
local OllieAnim

local OllieHack = script.Parent:FindFirstChild("OllieThrust")
if (OllieHack == nil) then
    OllieHack = Instance.new("BodyThrust")
    OllieHack.Name = "OllieThrust"
    OllieHack.force = Vector3.new(0,0,0)
    OllieHack.location = Vector3.new(0,0,-2)
    OllieHack.Parent = Board
end

local lastaction = nil
local lasttime = nil
local jumpok = true

function didAction(action)
    lastaction = action
    lasttime = time()
end



function onAxisChanged(axis)
    Board.Steer = Controller.Steer
    Board.Throttle = Controller.Throttle

    if (Board.Steer == -1) then
        print("Left")
        --CoastingAnim:Stop(1)
        KickAnim:Stop()
        OllieAnim:Stop()
        RightAnim:Stop(.5)
        LeftAnim:Play(.5)
        didAction("left")
    end

    if (Board.Steer == 1) then
        print("Right")
        KickAnim:Stop()
        --CoastingAnim:Stop(1)
        LeftAnim:Stop(.5)
        OllieAnim:Stop()
        RightAnim:Play(.5)
        didAction("right")
    end

    if (Board.Steer == 0) then
        print("Straight")

        KickAnim:Stop()
        LeftAnim:Stop(.5)
        OllieAnim:Stop()
        RightAnim:Stop(.5)

        if (lastaction == "go" and time() - lasttime < .1) then

        end
        didAction("go")
        --CoastingAnim:Play(1)


    end
end

function enterAirState()
    -- gyrate towards vertical position for better landing
    Gyro.maxTorque = Vector3.new(100, 0, 100)
    jumpok = false
end

function exitAirState()
    -- turn off gyro
    Gyro.maxTorque = Vector3.new(0,0,0)
    jumpok = true
end

function enterPushingState()
    KickAnim:Play()
end

function onMoveStateChanged(newState, oldState)
    print(oldState)
    print(newState)
    -- do state exits here
    if oldState == Enum.MoveState.AirFree then exitAirState() end

    -- do state transitions here

    -- do state entries here
    if newState == Enum.MoveState.AirFree then enterAirState() end
    if newState == Enum.MoveState.Pushing then enterPushingState() end
end


-- initialization/finalization stuff

function makeGyro(humanoid)
    Gyro = Instance.new("BodyGyro")
    Gyro.Name = "SkateboardGyro"
    Gyro.maxTorque = Vector3.new(0,0,0) -- start off
    Gyro.P = 50
    Gyro.D = 50
    Gyro.Parent = humanoid.Parent.Torso
end

function onButtonChanged(button)
    if button == Enum.Button.Dismount then
        Board.ControllingHumanoid.Jump = Controller:getButton(Enum.Button.Dismount)
    end
    if button == Enum.Button.Jump then
        if Controller:getButton(Enum.Button.Jump) and jumpok then
            jumpok = false
            KickAnim:Stop()
            LeftAnim:Stop(.5)

            RightAnim:Stop(.5)
            OllieAnim:Play(0,1,4)
            Board.StickyWheels = false
            Board:ApplySpecificImpulse(Vector3.new(0,100,0))
            OllieHack.force = Vector3.new(0,1200,0)
            didAction("jump")
            delay(.1, function() if (OllieHack ~= nil) then OllieHack.force = Vector3.new(0,0,0) end end)
        else
            Board.StickyWheels = true
        end
    end
end

function onEquip(humanoid, controller)
    print("Board equipped")
    print(controller)
    if not Controller then -- debounce
        Controller = controller

        makeGyro(humanoid)
        controller.AxisChanged:connect(onAxisChanged)
        Board.MoveStateChanged:connect(onMoveStateChanged)
        CoastingAnim = humanoid:loadAnimation(Board.coastingpose)   
        LeftAnim = humanoid:loadAnimation(Board.leftturn)
        RightAnim = humanoid:loadAnimation(Board.rightturn)
        OllieAnim = humanoid:loadAnimation(Board.ollie)
        --OllieAnim:AdjustSpeed(2)
        KickAnim = humanoid:loadAnimation(Board.boardkick)
        CoastingAnim:Play()

        Controller:bindButton(Enum.Button.Jump, "Ollie")
        Controller:bindButton(Enum.Button.Dismount, "Dismount")
        Controller.ButtonChanged:connect(onButtonChanged)
    end
end

function onUnequip(board)
    print("Board unequipped")
    Controller = nil
    Gyro.Parent = nil
    Gyro= nil
    CoastingAnim:Stop()
    KickAnim:Stop()
    CoastingAnim = nil
    KickAnim = nil
    LeftAnim:Stop()
    LeftAnim = nil
    RightAnim:Stop()
    RightAnim = nil
    OllieAnim:Stop()
    OllieAnim = nil

    if (OllieThrust ~= nil) then
        OllieThrust:Remove()
        OllieThrust = nil
    end
end

-- connect events

Board.equipped:connect(onEquip)
Board.unequipped:connect(onUnequip)

-- main program

-- we could have missed the onEquip event on script start
if Board.Controller and not Controller then

    onEquip(Board.ControllingHumanoid, Board.Controller)

end
0
Please format it properly, thank you joritochip 705 — 5y
0
Umm, please format it fully xD. You're switching from just plain text to Code Block every now and then, I can't read it too well. TheOnlySmarts 233 — 5y

Answer this question