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

Why is my output saying to use a nil value???

Asked by 7 years ago

I am new to scripting and I am teaching myself which is going smoothly except the output is saying I need a nil value to fix my script

local play = script.Parent
local Frame = game.StarterGui.Check.Frame
local Click = play.MouseButton1Click:connect(onClick)
local Check = game.StarterGui.Check

Check.Frame.Visible = true

function onClick(play)
Check.Frame.Visible = nil
end

the output says attempt to call a nil value

I even tried making the script:

local play = script.Parent
local Frame = game.StarterGui.Check.Frame
local Click = play.MouseButton1Click:connect(onClick)
local Check = game.StarterGui.Check

Check.Frame.Visible = true

function onClick(play)
Check.Frame.Visible = nil
if nil == true then
    Check.Frame.Visible = false
end
end


Please help!

0
"attempt to call a nil value" doesn't mean to use a nil value, it's saying you're trying to index (use) a non-existent value. TheeDeathCaster 2368 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

It's not recommending that you try to call a nil value, it's letting you know that you've already tried.

The problem is that onClick does not exist until line 8 (using your first script), but you attempt to use it on line 3. Line 3 should be after you have defined the function.

In the future, also include what line the error is occurring on, or let us know if there isn't one.

Ad

Answer this question