You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
get rid of error
What is the issue? Include screenshots / videos if possible!
attempt to call a nil value - line 96
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)
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
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)
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.
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