在我的游戏中,我做了一个你可以冲刺的功能。我已经将脚本的动画部分与主要的冲刺部分分开了。我收到了错误消息"Workspace.Vlo_tz.SprintingAnimation:19: Expected ')' (to close '(' at column 29), got ','".,此代码用于角色的动画和冲刺条
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发布于 2020-06-12 11:29:16
第19行如下:if stamina.Position <= (-0.343, 0, 0.274, 0) then
你在几个不同的地方有这个检查,但是这不是有效的lua,并且你不能像这样比较UDim2的值。您必须逐个检查这些值。
local isLessThanX = stamina.Position.X.Scale <= -0.343
local isLessThanY = stamina.Position.Y.Scale <= 0.274
if isLessThanX and isLessThanY thenhttps://stackoverflow.com/questions/62336184
复制相似问题