![](/img/trans.png)
[英]attempt to index nil with 'leaderstats' error in roblox studio
[英]Roblox studio error attempt to call a nil value
我的代码是这样的
player = game.Players.LocalPlayer
while game.Players.LocalPlayer == nil do
player = game.Players.LocalPlayer
wait(0.1)
end
local mouse = player:GetMouse()
mouse.Button1Up:Connect(addpoints())
function addpoints()
print("add points")
end
这是工具中的本地脚本,该工具位于入门包中。 在上面写着```mouse.Button1Up`` 的那一行,我尝试调用一个 nil 值时出错,但我从使用断点知道鼠标不是 nil
您的问题是 addPoints 功能在您尝试连接时不存在。
因此,要解决您的问题,1) 将 function 定义移到连接上方,以及 2) 删除括号,以便您传递 function 本身。
function addpoints()
print("add points")
end
mouse.Button1Up:Connect(addpoints)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.