Lua 按一个按钮,文本增加+;1在roblox工作室

Lua 按一个按钮,文本增加+;1在roblox工作室,lua,roblox,Lua,Roblox,有人能帮我解决这个错误吗? 我有一个按钮叫做“TextButton”,我有一个文本叫做“TextLabel”,当我按下“TextButton”按钮时,我需要做的是使“TextLabel”增加1,有人能帮我吗 function script.Parent.MouseButton1Click:Connect(function() print("working..?..") script.Parent.ValorVoto.Value = script.Parent.

有人能帮我解决这个错误吗?
我有一个按钮叫做“TextButton”,我有一个文本叫做“TextLabel”,当我按下“TextButton”按钮时,我需要做的是使“TextLabel”增加1,有人能帮我吗

function script.Parent.MouseButton1Click:Connect(function()
    print("working..?..")
    script.Parent.ValorVoto.Value = script.Parent.ValorVoto.Value+1
    script.Parent.Parent.TextLabel = "clicks: "..script.Parent.ValorVoto.Value
    end
    
script.Parent.Parent.TextButton.MouseButton1Down:Connect(clicking)


我认为您有语法错误。看起来您正在定义一个函数,但也尝试将该函数立即连接到TextButton。尝试命名函数
单击
,然后将其传递到连接中

function clicking()
    print("working..?..")
    local vv = script.Parent.ValorVoto
    vv.Value = vv.Value + 1
    script.Parent.Parent.TextLabel.Text = "clicks: " .. tostring(vv.Value)
end
    
script.Parent.MouseButton1Click:Connect(clicking)

此脚本中有2个错误:

  • 第4行,在引用文本标签后添加一个
    .Text
  • 正如Kylaa所说,第7行有一个错误,您可以去掉该行,因为您的函数已经被一个事件调用了。您不需要调用该函数,而且您尝试调用的函数不存在
  • 如果它已经在侦听事件,则不会将其标记为函数
  • script.Parent.MouseButton1Click:Connect(函数()
    打印(“工作…”)
    script.Parent.ValorVoto.Value=script.Parent.ValorVoto.Value+1
    script.Parent.Parent.textlab.Text=“单击:”…script.Parent.ValorVoto.Value
    结束
    
    你确定你的正在运行吗?如果你在按钮连接之外添加打印语句,它会启动吗?@Kylaaa是的,它运行正常,但我不明白为什么localscript不运行,可能是某些错误或拼写错误,但我检查了代码,没关系,我真的很困惑