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

Gui Button Script will not work?

Asked by 8 years ago

Ive got the script in a localscript inside startergui. When i click it, it says "attempt to call a nil value" in the output. How would i get this to work?**

function onClick()
    if game.Players.LocalPlayer.Character.Head.Transparency == 1 then
        print("yes")
    else
        print("no")
    end

end
script.Parent.MouseButton1Click:connect()

2 answers

Log in to vote
1
Answered by 8 years ago

You forgot to pass the function "onClick" as a parameter to "connect"

Corrected:

function onClick()
    if game.Players.LocalPlayer.Character.Head.Transparency == 1 then
        print("yes")
    else
        print("no")
    end

end
script.Parent.MouseButton1Click:connect(onClick)
Ad
Log in to vote
0
Answered by 8 years ago

function onClick() if game.Players.LocalPlayer.Character.Head.Transparency == 1 then print("yes") else print("no") end

end script.Parent.MouseButton1Click:connect(onClick)

Answer this question