Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Hello! I made this module script, but it doesn't work. Can someone help me?

Here's the Module Script;

local NotificationModule = {}
local NotificationLabel = game.StarterGui.NotificationGui.NotificationLabel

function NotificationModule.NewNotification(text, duration)
	local Notification = NotificationLabel:Clone()
	Notification.Text = text
	
	Notification:TweenPosition(UDim2.new(0.829, 0,0.876, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .35)
	wait(duration)
	Notification:TweenPosition(UDim2.new(1, 0,0.876, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .35)
end

return NotificationModule

The module is supposed to display a GUI with the wanted text and duration.

I call the module which is parented in a script in workspace.

Here's the script that calls the module;

local NotificationModule = require(script.NotificationModule)

wait(5)

NotificationModule.NewNotification("Hello!", 6.5)

I have the wait so it doesn't fire the code when I join the game.

The script doesn't work and I don't know what to do. Thanks to anyone who helps!

1 comment

2

You didn't set NotificationLabel parent to player gui

1 answer

✓ Accepted answer

Try setting your notification parent to player gui:

(I'm considering you call this from a local script)

local NotificationModule = {}
local NotificationLabel = game.StarterGui.NotificationGui.NotificationLabel

function NotificationModule.NewNotification(text, duration)
    local Notification = NotificationLabel:Clone()
    Notification.Text = text
    Notification.Parent =  game.Players.LocalPlayer.PlayerGui

    Notification:TweenPosition(UDim2.new(0.829, 0,0.876, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .35)
    wait(duration)
    Notification:TweenPosition(UDim2.new(1, 0,0.876, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .35)
end

return NotificationModule

This discussion is preserved as it was. New answers, comments, and votes are closed.