0

could someone help me with this error?
I have a button created called "TextButton" and I have a text called "TextLabel", what I need to do is make the "TextLabel" increase by 1 when I press the "TextButton" button, could someone help me with this please.

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)

1

2

Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64
  • Are you sure that your [LocalScript](https://developer.roblox.com/en-us/api-reference/class/LocalScript) is running? If you add print statements outside the button connection, does it fire? – Kylaaa Jan 06 '21 at 18:25
  • @Kylaaa yes, it's running properly, but I don't understand why the localscript doesn't run Maybe it's some mistake or something's misspelled, but I've checked the code, and it's all right, I'm really very confused – Braian Durán Jan 06 '21 at 18:31

2 Answers2

1

I think you've got a syntax error. It looks like you're defining a function, but also trying to connect that function immediately to the TextButton. Try naming your function clicking, and then passing that into the connection.

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)
Kylaaa
  • 6,349
  • 2
  • 16
  • 27
0

You have 2 errors in this script:

  1. Line 4, add a .Text after referencing the TextLabel.
  2. As Kylaa said, there is an error with line 7, you can just get rid of that line because your function was called with an event already. You don't need to recall that function, plus the function you're trying to call doesn't exist.
  3. You don't mark it as a function if it's already listening for an event.
script.Parent.MouseButton1Click:Connect(function()
    print("working..?..")
    script.Parent.ValorVoto.Value = script.Parent.ValorVoto.Value+1
    script.Parent.Parent.TextLabel.Text = "clicks: "..script.Parent.ValorVoto.Value
end
May
  • 68
  • 6