Roblox补间操作触发“attempt to call a table value”错误求助
Roblox TweenService 报错:attempt to call a table value 解决方法
错误原因
报错Workspace.core.Script:4: attempt to call a table value的核心问题是:你直接将TweenInfo当作函数调用。在Roblox Lua中,TweenInfo是一个类,必须通过TweenInfo.new()方法来创建实例,而非直接调用TweenInfo()。
修正后的代码
local temp = workspace.values.core.temp local tw = game:GetService("TweenService") while true do -- 使用 TweenInfo.new() 创建补间信息实例 local tweenInfo = TweenInfo.new(10-(temp.Value/200), Enum.EasingStyle.Circular, Enum.EasingDirection.InOut) local g = tw:Create(script.Parent, tweenInfo, {Size = Vector3.new(5,5,5)}) g:Play() g.Completed:Wait() end
额外建议
- 给变量添加
local关键字,避免全局变量污染,这是Roblox Lua的标准编程习惯。 - 若后续需要动态调整补间参数,确保
temp.Value是有效的数值类型,避免因类型错误引发其他问题。
内容的提问来源于stack exchange,提问作者rver
相关产品推荐
相关产品推荐

