Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this click function not working? It doesn't detect the click!

Asked by 7 years ago

This should have an easy answer, I do this kind of functions all the time, I don't know why this isn't working!!

script.Parent is a TextButton, so that's not the problem. The only problem is with the function, nothing inside, it doesn't detect the click. I hope you can find a solution.

function a()
    local plr = game.Players.LocalPlayer
    if plr:GetRankInGroup(2990423)>= 3 then
        if script.Parent.Parent.Playing.Value == false then
            script.Parent.Parent.Playing.Value = true
            script.Parent.Announcement:Play()
        elseif script.Parent.Parent.Playing.Value == true then
            script.Parent.Parent.Playing.Value = false
            script.Parent.Announcement:Stop()
        end
    end
end

script.Parent.MouseButton1Click:connect(a)
1
add a print('Hello!') right after the function a() line, to see if it comes into the function. RubenKan 3615 — 7y
0
Make sure the text button isn't covered up at all, and is active. Also do what Ruben said, it's good to debug things and test if functions are actually being called or not. And finally, you should use :Connect because :connect is now Deprecated and could be removed at any time. plasma_node 343 — 7y
0
Also make sure this is in a local script plasma_node 343 — 7y
0
Is this the full code or might you have an infinite loop before the event? Also, try doing as RubenKan suggested and try debugging your code. M39a9am3R 3210 — 7y
View all comments (2 more)
0
Thanks! I'm sorry I can't upvote. I tried what Ruben said before, it doesn't call the function, I'll try putting it in a LocalScript and I'll change :connect for :Connect. That's the whole script, how do I debug it? iDelta_Dev 2 — 7y
0
I tried every sigle advice, none worked. :( iDelta_Dev 2 — 7y

Answer this question