Hidden Is A Ninja
Hidden Is A Ninja

Reputation: 1

Roblox Problem: Expected ')' (to close '(' at column 18), got '='

Hi I'm trying to make a flight script and I just need help with the ")" I honestly can't find where to put it. I know its a rookie mistake and I'm sorry for the waste of time. I have to over explain this and I'm sorry but I can't post any other way.

local camera = game.Workspace.CurrentCamera;

local character = game.Players.LocalPlayer.ChracaterAdded:Wait();
    local F = game.Players.LocalPlayer.Backpack.Bold
local hrp = character:WaitForChild("HumanoidRootPart");
local humanoid = character:WaitForChild("Humanoid");
local animate = character:WaitForChild("Animate");

while (not character.Parent) do character.AncestryChanged:Wait(); end
local idleAnim = humanoid:LoadAnimation(script:WaitForChild("IdleAnim"));
local moveAnim = humanoid:LoadAnimation(script:WaitForChild("MoveAnim"));
local lastAnim = idleAnim;

local bodyGyro = Instance.new("BodyGyro");
bodyGyro.maxTorque = Vector3.new(1, 1, 1)*10^6;
bodyGyro.P = 10^6;

local bodyVel = Instance.new("BodyVelocity");
bodyVel.maxForce = Vector3.new(1, 1, 1)*10^6;
bodyVel.P = 10^4;

local isFlying = false;
local isJumping = false;
local movement = (forward = 0, backward = 0, right = 0, left = 0);
local FAD = F.Flying;

--------------Functions--------------

local function setFlying(flying)
    isFlying = flying;
    bodyGyro.Parent = isFlying and hrp or nil;
    bodyVel.Parent = isFlying and hrp or nil;
    bodyGyro.CFrame = hrp.CFrame;
    bodyVel.Velocity = Vector3.new();

    animate.Disabled = isFlying

    if (isFlying) then
        FAD.Transparency = 1
        lastAnim = idleAnim;
        lastAnim:Play();
    else
        FAD.Transparency = 0
        lastAnim:Stop();
    end
end

local function onUpdate(dt)
    if (isFLying) then
        local cf = camera.CFrame;
        local direction = cf.rightVector*(movement.right - movement.left) + cf.lookVector*(movement.foward - movement.backward);

    if (direction:Dot(direction) > 0) then
        direction = direction.unit;
    end

    bodyGyro.CFrame = cf;
    bodyVel.Velocity = direction * humanoid.WalkSpeed * 3
    end
end

local function onJumpRequest()
    if (not humanoid or humanoid:GetState() == Enum.HumanoidStateType.Dead) then
        return;
    end

    if (isFlying) then
        setFlying(false);
        isJumping = false;
    else if (isJumping) then
        wait(0.5)setFlying(true);
    end
end

local function onStateChange(old, new)
    if (new == Enum.HumanoidStateType.Landed) then

        isJumping = false;
    elseif (new == Enum.HumanoidStateType.Jumping) then
        isJumping = true;
    end
end

local function movementBind(actionName, inputState, inputObject)
    if (inputState == Enum.UserInputState.Begin) then
        movement[actionName] = 1;
    elseif (inputState == Enum.UserInputState.End) then
        movement[actionName] = 0;
    end

    if (isFlying) then
        local isMoving = movement.right + movement.left + movement.foward + movement.backward > 0;
        local nextAnim = isMoving and moveAnim or idleAnim;
        if (nextAnim ~= lastAnim) then
            lastAnim:Stop();
            lastAnim = nextAnim;
            lastAnim:Play();
        end
    end
    return Enum.ContextActionResult.Pass;

end
-------------Connections-------------

humanoid.StateChanged:Connect(onStageChange);
game:GetService("UserInputService").JumpRequest:Connect(onJumpRequest);


game:GetService("ContextActionService"):BindAction("forward", movementBind, false, Enum.PlayerActions.CharacterFoward);
game:GetService("ContextActionService"):BindAction("backward", movementBind, false, Enum.PlayerActions.CharacterBackard);
game:GetService("ContextActionService"):BindAction("left", movementBind, false, Enum.PlayerActions.CharacterLeft);
game:GetService("ContextActionService"):BindAction("right", movementBind, false, Enum.PlayerActions.CharacterRight);

    game:GetService("RunService").RenderStepped:Connect(onUpdate)

Upvotes: 0

Views: 144

Answers (1)

Jaguar-515
Jaguar-515

Reputation: 108

In line 18, movement's value should be a dictionary, rather than variables inside the parentheses.

local movement = {forward = 0, backward = 0, right = 0, left = 0}

Upvotes: 2

Related Questions