Attempt to call a nil value

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    get rid of error
  2. What is the issue? Include screenshots / videos if possible!
    attempt to call a nil value - line 96
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

nothing…

script.Parent.Rules.MouseButton1Click:Connect(function(notification)
	notification("Information!", "Game Rules can be found on the games description!",nil,15) -- line error is giving
end)

What exactly is notification defined as…? And shouldn’t you be referring to the TextLabel’s Text instead?

local notification = function(Title, Txt, Icon, Time)
	game:GetService("StarterGui"):SetCore("SendNotification", {
		Title = Title,
		Text = Txt,
		Icon = Icon,
		Duration = Time -- Defaults to 5 secs
	})
end

It might be because you’re setting 2 variables to be the same thing, maybe change the

Title = Title

To

Title = title

? Variables are known to be case-sensitive

Why is there a notification argument in the MouseButton1Click event?

script.Parent.Rules.MouseButton1Click:Connect(function()
	notification("Information!", "Game Rules can be found on the games description!",nil,15) -- line error is giving
end)
2 Likes

Whenever you click on the Rules button, it would clone a GUI showing the game rules, however, this isn’t possible due to this error.

MouseButton1Click doesn’t pass any arguments to the function. You’re setting the variable notification to nil, then calling it. Hence, “attempt to call a nil variable”

Just change :Connect(function(notification) to :Connect(function() and it should be fixed.

why do u have to put a nil value in it?

local notification = function(Title, Txt, Icon, Time)
	game:GetService("StarterGui"):SetCore("SendNotification", {
		Title = Title,
		Text = Txt,
		Icon = Icon,
		Duration = Time -- Defaults to 5 secs
	})
end

That function is completely fine, you just need to change your MouseButton1Click script.