首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >SprintingAnimation:19:应为')‘(关闭'(’在第29列),获取',‘

SprintingAnimation:19:应为')‘(关闭'(’在第29列),获取',‘
EN

Stack Overflow用户
提问于 2020-06-12 09:39:16
回答 1查看 87关注 0票数 0

在我的游戏中,我做了一个你可以冲刺的功能。我已经将脚本的动画部分与主要的冲刺部分分开了。我收到了错误消息"Workspace.Vlo_tz.SprintingAnimation:19: Expected ')' (to close '(' at column 29), got ','".,此代码用于角色的动画和冲刺条

代码语言:javascript
运行
复制
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
local players = game:GetService("Players")
local stamina = players.LocalPlayer.PlayerGui.StaminaHealth.MainFrame.Stamina

UIS.InputBegan:connect(function(input)
    local humanoid = Player.Character.Humanoid
    if input.KeyCode == Enum.KeyCode.LeftShift and humanoid:GetState() == Enum.HumanoidStateType.RunningNoPhysics and humanoid.MoveDirection.Magnitude > 0 then
        local Anim = Instance.new('Animation')
        Anim.AnimationId = 'rbxassetid://05168161960'
        PlayAnim = Character.Humanoid:LoadAnimation(Anim)
        PlayAnim:Play()

        while true do
            wait(0.05)

            if stamina.Position <= (-0.343, 0, 0.274, 0) then
                stamina.Position = UDim2.new(-0.343, 0, 0, 0)
            else
                stamina.Position = stamina.Position - UDim2.new(0.01, 0, 0, 0)
            end
        end
    end
end)

UIS.InputEnded:connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        PlayAnim:Stop()

        while true do
            wait(0.005)

            if stamina.Position >= (0.487, 0, 0.274, 0) then
                stamina.Position = UDim2.new(0.487, 0, 0, 0)
            else
                stamina.Position = stamina.Position + UDim2.new(0.01, 0, 0, 0)
            end
        end
    end
end)

local humanoid = Player.Character.Humanoid
if humanoid.MoveDirection.Magnitude == 0 then
    PlayAnim:Stop()

    while true do
        wait(0.005)

        if stamina.Position >= (0.487, 0, 0.274, 0) then
            stamina.Position = UDim2.new(0.487, 0, 0, 0)
        else
            stamina.Position = stamina.Position + UDim2.new(0.01, 0, 0, 0)
        end
    end
end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-12 11:29:16

第19行如下:if stamina.Position <= (-0.343, 0, 0.274, 0) then

你在几个不同的地方有这个检查,但是这不是有效的lua,并且你不能像这样比较UDim2的值。您必须逐个检查这些值。

代码语言:javascript
运行
复制
local isLessThanX = stamina.Position.X.Scale <= -0.343
local isLessThanY = stamina.Position.Y.Scale <= 0.274
if isLessThanX and isLessThanY then
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62336184

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档