【问题标题】:Got Error "Argument 3 missing or nil" in Roblox在 Roblox 中出现错误“Argument 3 missing or nil”
【发布时间】:2020-12-04 12:57:20
【问题描述】:

我在 Roblox 中编码,遇到一个错误,告诉我参数 3 丢失或为零。这是我的代码

local tweenservice = game:GetService("TweenService")
local part = workspace.TruckBlock

local Tween = tweenservice:Create(part,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0,{Position = Vector3.new(5.642, 1.65, -17.99)}))
wait(5)
Tween:Play()

我是一个新的编码员,我真的不明白出了什么问题。

【问题讨论】:

    标签: roblox


    【解决方案1】:

    错误告诉您,您调用的函数需要三个参数,而您只提供了两个。 TweenService:Create() 期望改变一个目标、一些补间信息和一个道具字典。

    您的代码包含所有正确的部分,但您在错误的位置放置了右括号:

    e,0,{Position = Vector3.new(5.642, 1.65, -17.99)}))
       ^ the ) needs to go here                      ^ not here
    

    这会导致 props 的字典被传递到补间信息构造函数中。因此,TweenService:Create() 没有得到三个参数,而是只得到两个。

    很难发现错误,因为您已将所有内容放在一行中。将内容分成多行后,阅读起来会更容易,错误消息也会更容易理解。

    local tweenservice = game:GetService("TweenService")
    local part = workspace.TruckBlock
    
    local tweenInfo = TweenInfo.new(1, -- time
        Enum.EasingStyle.Linear,       -- easing style
        Enum.EasingDirection.Out,      -- easing direction
        0,                             -- repeat count
        false,                         -- reverses
        5)                             -- delay
    
    local props = {
        Position = Vector3.new(5.642, 1.65, -17.99),
    }
    
    local Tween = tweenservice:Create(part, tweenInfo, props)
    Tween:Play()
    

    【讨论】:

    猜你喜欢
    • 2018-05-27
    • 2021-06-24
    • 1970-01-01
    • 1970-01-01
    • 2020-08-25
    • 1970-01-01
    • 2022-01-10
    • 2023-03-25
    • 2020-07-31
    相关资源
    最近更新 更多