The notification to run a function when clicked.
It keeps saying the clicked callback is nil.
Client Code
local Remote = game.ReplicatedStorage.Remotes.Events.NotifyPlayer
Remote.OnClientEvent:Connect(function(text, duration, clicked)
local template = script.Parent.Clip.Template:Clone()
template.Text = text
template.Visible = true
template.Parent = script.Parent.Clip
template.Notification:Play()
template.Button.MouseButton1Click:Connect(function()
clicked()
end)
if duration < math.huge then
task.wait(duration)
template:Destroy()
end
end)
Server Code
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Mods,Remotes = ReplicatedStorage.Modules,ReplicatedStorage.Remotes
local clicked = function(plr)
if game["Run Service"]:IsServer() then
Remotes.Functions.invokeInfo:InvokeClient(plr)
elseif game["Run Service"]:IsClient() then
Remotes.Functions.InvokeInfo:InvokeServer(game.Players.LocalPlayer)
end
end
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
Remotes.Events.NotifyPlayer:FireClient(plr, "Welcome! Click to view important information.", 10, clicked)
end)
end)
Error
19:33:01.203 Players.Jerold09362.PlayerGui.Notifications.Notification Client:11: attempt to call a nil value - Client - Notification Client:11
19:33:01.203 Stack Begin - Studio
19:33:01.203 Script 'Players.Jerold09362.PlayerGui.Notifications.Notification Client', Line 11 - Studio - Notification Client:11
19:33:01.204 Stack End - Studio