Проблема Roblox: ожидается ')' (закрыть '(' в столбце 18), получено '=' - PullRequest
0 голосов
/ 16 июня 2020

Привет, я пытаюсь сделать сценарий полета, и мне просто нужна помощь с ")", честно говоря, не могу найти, куда его положить. Я знаю, что это ладья ie ошибка, и извиняюсь за потерю времени. Я должен излишне объяснять это, и мне очень жаль, но я не могу опубликовать другой способ.

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)

1 Ответ

2 голосов
/ 16 июня 2020

В строке 18 значением движения должно быть словарь , а не переменные внутри скобок.

local movement = {forward = 0, backward = 0, right = 0, left = 0}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...