#player tilt/tween broken after putting it in a module

1 messages · Page 1 of 1 (latest)

quasi igloo
#

trying to move things out of a local script into a module and everything was going fine until it came to undoing the tilt once the player input ended, what i originally had wasnt working, and when i tried to do anything else using 0 it didnt work and broke another thing, and when i thought i fixed with -Orientation[direction[1]] but it did NOT work (i barely understand what im doing 🙏 🥀 )

module
module.SimpleTables = function()
    local Orientation = { -- Stores current X/Y axis tilt
        -- ["Axis"] = Degree;
        ["X"] = 0; 
        ["Y"] = 0
    }
    local Move_Input = { -- Stores input tilt info
        -- [Input Keycode] = {"Axis", +/- direction};
        [Enum.KeyCode.W] = {"X", 1};
        [Enum.KeyCode.S] = {"X", -1};
        [Enum.KeyCode.D] = {"Y", -1};
        [Enum.KeyCode.A] = {"Y", 1};
    }
    local Animations = {}
    return Orientation, Move_Input, Animations
end

module.CharacterTween = function(direction, inputState, character) 
        other code
        if inputState == "Began" and not module.Movement.status.holding then 
        Orientation[direction[1]] = module.Movement.config.tiltDegree * direction[2] -- Change orientation info
    else -- Else if input state is ended
        if Orientation[direction[1]] == module.Movement.config.tiltDegree * direction[2] or not module.Movement.status.idling then
            print(Orientation[direction[1]])
            Orientation[direction[1]] = 0 -- Reset orientation info
        end
    end
    local info = TweenInfo.new(0.3, Enum.EasingStyle.Linear)
    local handledC0 = defaultC0 * CFrame.Angles(math.rad(Orientation.X), math.rad(Orientation.Y), 0) -- if i do any other method with 0 this line breaks, and the method currently used does nothing
    tweenService:Create(character.HumanoidRootPart:FindFirstChildWhichIsA("Motor6D"), info, {C0 = handledC0}):Play()
end

i know very little about tweens 💔

gaunt axleBOT
#

studio** You are now Level 2! **studio