My notification script isn't working

I am trying to make a script in which if a notification is sent it moves another notification up. I already had it so the new notification goes to top but that didn’t work for me. This is the code I wrote so far.

local tweenservice = game:GetService("TweenService")
game.ReplicatedStorage.Announcer.OnClientEvent:Connect(function(text,color,title)
	for i,v in pairs(script.Parent.List:GetChildren()) do
		if v:IsA("Frame") then
			local YPos = v.Position.Y-1.2
			tweenservice:Create(v.Position,TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0),{Y = UDim.new(YPos,0)}):Play()
		end
	end
	local clone = script.Notification:Clone()
	clone.Parent = script.Parent.List
	clone.Position = UDim2.new(1.05,0,0,0)
	clone.Title.Text = title
	clone.Info.Text = text
	clone.i.ImageColor3 = color
	clone.Divider.BackgroundColor3 = color
	clone.Background.BackgroundColor3 = color
	game.Workspace.Game.Sounds.UIsounds.Notification.TimePosition = 0.5
	game.Workspace.Game.Sounds.UIsounds.Notification:Play()
	tweenservice:Create(clone,TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0),{Position = UDim2.new(0,0,0,0)}):Play()
	wait(5)
	tweenservice:Create(clone,TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0),{Position = UDim2.new(1.05,0,0,0)}):Play()
		wait(1)
		clone:Destroy()
end)

but for now focus on the for i,v in pairs(script.Parent.List:GetChildren()) do if v:IsA("Frame") then local YPos = v.Position.Y-1.2 tweenservice:Create(v.Position,TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0),{Y = UDim.new(YPos,0)}):Play() end end

because that’s where I am having issues. In the console there is an error that goes like:


Please help

1 Like

try changing udim to udim2 in the line

1 Like

Yeah, no. I am trying to move the frame only on the Y axis because it moves on the X axis too. If I change it to UDim2 it could break a tween. I think atleast…

Try changing the for loop code to this:

for i,v in pairs(script.Parent.List:GetChildren()) do
	if v:IsA("Frame") then
		local YPosScale = v.Position.Y-1.2
        local YPosOffset = v.Position.Y
		tweenservice:Create(v.Position,TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0),{Position = UDim.new(v.Position.X.Scale, v.Position.X.Offset, YPosScale, YPosOffset)}):Play()
	end
end
1 Like

Nope… Still the same error. Idk what’s the problem…

I forgot to add scale and offset to local YPosScale and local YPosOffset sorry, try this instead:

for i,v in pairs(script.Parent.List:GetChildren()) do
	if v:IsA("Frame") then
		local YPosScale = v.Position.Y.Scale-1.2
        local YPosOffset = v.Position.Y.Offset
		tweenservice:Create(v,TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0),{Position = UDim.new(v.Position.X.Scale, v.Position.X.Offset, YPosScale, YPosOffset)}):Play()
	end
end

Wait wouldn’t that break the tween on the X axis too?

For example this one:

tweenservice:Create(clone,TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0),{Position = UDim2.new(1.05,0,0,0)}):Play()

I think there should be no problem because you are running the tweens on different guis first one is tweening Frame and other one is tweening Clone

Yeah but what if the ui does a the tween? Those are the same UIs

They are not the same UI the first one is v and the second one is Notification’s clone. And even if they were same UI, in the code it waits 5 seconds before tweening the clone so there should be no problem

the v is supposed to be an another notification

It’s another notification but it’s not the same notification

image
the gonna is stuck see? it isnt moving

oh then try adding a wait(0.5) after the for loop to wait for first tween to end.
like this:

for i,v in pairs(script.Parent.List:GetChildren()) do
	if v:IsA("Frame") then
		local YPosScale = v.Position.Y.Scale-1.2
        local YPosOffset = v.Position.Y.Offset
		tweenservice:Create(v,TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0),{Position = UDim.new(v.Position.X.Scale, v.Position.X.Offset, YPosScale, YPosOffset)}):Play()
	end
end
wait(0.5)

image
nope, I didn’t think it would work.