Basically I’m trying to make this module where it gives you a custom badge notification, not just a regular badge notification. For some reason, it just says “Attempt to Index Nil With PlayerGui”. Can someone help me out here?
local custom = {}
local gui = script:FindFirstChild("CustomBadgeNotificationUI")
local badgeservice = game:GetService("BadgeService")
function custom:CreateBadgeNotification(badgeid)
local success, result = pcall(function()
return badgeservice:GetBadgeInfoAsync(badgeid)
end)
if success then
local cloneui = gui:Clone()
cloneui.Parent = game.Players.LocalPlayer.PlayerGui
local frame = cloneui:FindFirstChild("MainFrame")
local image = frame:FindFirstChild("BadgeIcon")
local title = frame:FindFirstChild("BadgeName")
local description = frame:FindFirstChild("BadgeDescription")
image.Image = "rbxassetid://"..result.IconImageId
title.Text = "You won "..result.Name.."!"
description.Text = result.Description
end
end
return custom
also another thing is this script keeps saying " SetCore: BadgesNotificationsActive has not been registered by the CoreScripts - Client - BadgeNotifDisable:1"
That detail changes nothing, only executable context (etc client or server) does
--!strict
--!optimize 2
local gui = script.CustomBadgeNotificationUI
local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")
local GetBadgeInfoAsync = BadgeService.GetBadgeInfoAsync
local Player = Players.LocalPlayer::Player
local PlayerGui = Player:WaitForChild("PlayerGui")::PlayerGui
return function(badgeid:number):()
local success, result = pcall(GetBadgeInfoAsync,BadgeService,badgeid)
if not success then return end
local cloneui = gui:Clone()
local frame = cloneui.MainFrame
local image = frame.BadgeIcon
local title = frame.BadgeName
local description = frame.BadgeDescription
image.Image = "rbxassetid://"..result.IconImageId
title.Text = "You won "..result.Name.."!"
description.Text = result.Description
cloneui.Parent = PlayerGui
end
Where are you calling the module script (i.e. using require on it)? Is that a normal script or a local script? Module scripts basically inherit if they are on the client or server from the script which calls them
The code within module scripts only runs if it gets required (require()).
Require can take a path rather than a number (e.g. require(script.Parent.MODULE))
i just started coding so i kinda dont know what ur saying tbh i was trying to use a modulescript for simpler ways, but using a remoteevent is the same thing, if i would have to use the function in the module, i would have to do function(player, badgeid) not function(badgeid)