Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Create(ty)
- return function(data)
- local obj = Instance.new(ty)
- for k, v in pairs(data) do
- if type(k) == 'number' then
- v.Parent = obj
- else
- obj[k] = v
- end
- end
- return obj
- end
- end
- function GetCurrentNotifyGuis(player)
- local guis = {}
- for i,v in pairs(player.PlayerGui:GetChildren()) do
- if v.Name == "Notification" then
- if v:findFirstChild("NotifyFrame") and v.NotifyFrame:IsA("Frame") then
- local guiInfo = {}
- table.insert(guiInfo,v)
- if v.NotifyFrame.Position.Y.Offset == -120 then
- table.insert(guiInfo,1)
- elseif v.NotifyFrame.Position.Y.Offset == -190 then
- table.insert(guiInfo,2)
- end
- table.insert(guis,guiInfo)
- end
- end
- end
- return guis
- end
- function getGui(title,message,image,timeout,callback)
- local gui = Create'ScreenGui'{
- Name = "Notification";
- Create'Frame'{
- Size = UDim2.new(0, 200, 0, 67);
- Style = Enum.FrameStyle.RobloxRound;
- Name = "NotifyFrame";
- Position = UDim2.new(1, 0, 1, -120);
- Create'ImageLabel'{
- Image = image;
- ZIndex = 2;
- Size = UDim2.new(0.26, 0, 0.95, 0);
- Name = "image";
- BackgroundTransparency = 1;
- };
- Create'TextLabel'{
- Text = title;
- Size = UDim2.new(0.69, 0, 0.3, 0);
- TextColor3 = Color3.new(1, 1, 1);
- TextWrap = true;
- Font = Enum.Font.ArialBold;
- Name = "Title";
- Position = UDim2.new(0.26, 0, 0, 0);
- BackgroundTransparency = 1;
- TextScaled = true;
- };
- Create'TextLabel'{
- Text = message;
- Size = UDim2.new(0.69, 0, 0.2, 0);
- TextColor3 = Color3.new(1, 1, 1);
- TextWrap = true;
- Name = "Message";
- Position = UDim2.new(0.26, 0, 0.6, 0);
- BackgroundTransparency = 1;
- TextScaled = true;
- };
- Create'ImageButton'{
- Image = "rbxasset://textures/ui/CloseButton.png";
- ZIndex = 4;
- Size = UDim2.new(0, 20, 0, 20);
- BackgroundTransparency = 1;
- Name = "Close";
- Position = UDim2.new(0.925, 0, -0.1, 0);
- };
- Create'TextButton'{
- ZIndex = 3;
- Name = "CloseOverlay";
- Text = "";
- Size = UDim2.new(1, 0, 1, 0);
- BackgroundTransparency = 1;
- };
- };
- };
- gui.NotifyFrame.CloseOverlay.MouseButton1Up:connect(function ()
- if callback then
- callback()
- end
- gui.NotifyFrame:TweenPosition(UDim2.new(1,0,1,gui.NotifyFrame.Position.Y.Offset),"Out","Linear",1,true,nil)
- wait(1)
- gui:Destroy()
- end)
- gui.NotifyFrame.Close.MouseButton1Up:connect(function ()
- if callback then
- callback()
- end
- gui.NotifyFrame.Close.Image = "rbxasset://textures/ui/CloseButton.png"
- gui.NotifyFrame:TweenPosition(UDim2.new(1,0,1,gui.NotifyFrame.Position.Y.Offset),"Out","Linear",1,true,nil)
- wait(1)
- gui:Destroy()
- end)
- gui.NotifyFrame.Close.MouseButton1Down:connect(function ()
- gui.NotifyFrame.Close.Image = "rbxasset://textures/ui/CloseButton_dn.png"
- end)
- gui.NotifyFrame.Close.MouseLeave:connect(function ()
- gui.NotifyFrame.Close.Image = "rbxasset://textures/ui/CloseButton.png"
- end)
- delay(timeout,function ()
- if gui:findFirstChild("NotifyFrame") then
- gui.NotifyFrame:TweenPosition(UDim2.new(1,0,1,gui.NotifyFrame.Position.Y.Offset),"Out","Linear",1,true,nil)
- wait(1)
- gui:Destroy()
- end
- end)
- return gui
- end
- _G.SendNotification = function (player,title,message,image,timeout,callback)
- if game.Players:findFirstChild(player.Name) == nil then return error("Argument 1 missing or nil") end
- if #GetCurrentNotifyGuis(player) > 2 then return end
- if type(title) ~= "string" then return error("Attempt to use '"..title.."' for string 'title'") end
- if type(message) ~= "string" then return error("Attempt to use '"..message.."' for string 'message'") end
- if type(image) ~= "string" then return error("Attempt to use '"..image.."' for content 'image'") end
- if type(timeout) ~= "number" then timeout = 999999 end
- local guis = GetCurrentNotifyGuis(player)
- if #guis ~= 0 then
- for i = 1,#guis do
- if guis[i][2] == 1 then
- guis[i][1].NotifyFrame:TweenPosition(UDim2.new(1,-200,1,-190),"Out","Linear",1,true,nil)
- else
- guis[i][1].NotifyFrame:TweenPosition(UDim2.new(1,0,1,-190),"Out","Linear",1,true,nil)
- game:GetService("Debris"):AddItem(guis[i][1],1)
- end
- end
- end
- local gui = getGui(title,message,image,timeout,callback)
- gui.Parent = player.PlayerGui
- gui.NotifyFrame:TweenPosition(UDim2.new(1,-200,1,-120),"Out","Quad",1,true,nil)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement