Advertisement
Sungmingamerpro13

New MainScript

Dec 10th, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 4.05 KB | None | 0 0
  1. --- Sungmingamerpro13
  2.  
  3. -- Services
  4. PlayerService = game:GetService('Players')
  5. TweenService = game:GetService('TweenService')
  6.  
  7. -- Variables
  8. DefaultMessageDelayTime = 4
  9. LetterInvertal = 0.05
  10. MessageWaitSigns = {',', '?', '.'}
  11. MessageWaitSignDelay = 1
  12.  
  13. MessageValue = game.ReplicatedStorage.Message
  14. ImageValue = game.ReplicatedStorage.Message.SpeakerImage
  15. SpeakerValue = game.ReplicatedStorage.Message.SpeakerName
  16. PlayerImageValue = game.ReplicatedStorage.Message.PlayerImage
  17. PlayerNameValue = game.ReplicatedStorage.Message.PlayerName
  18. HideDialogueEvent = game.ReplicatedStorage.Message.HideDialogueEvent
  19.  
  20. -- randomPlayer or NPC
  21.  
  22. local randomPlayer
  23.  
  24. PlayerImages = {}
  25.  
  26.  
  27. function MakePlayerImage(Player)
  28.     local Image = ''
  29.     local Success,Error = pcall(function()
  30.         local ID = PlayerService:GetUserIdFromNameAsync(Player.Name)or ''
  31.         local PlayerImage, IsReady = PlayerService:GetUserThumbnailAsync(ID, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
  32.         if IsReady == true then
  33.             -- Ready to use image
  34.             Image = tostring(PlayerImage)
  35.         else
  36.             -- Use alternative picture
  37.             Image = ("http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=%s"):format(Player.Name)
  38.         end
  39.     end)
  40.     if Success == true then
  41.         -- Successful
  42.     else
  43.         Image = ("http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=%s"):format(Player.Name)
  44.     end
  45.     PlayerImages[Player.Name] = Image
  46. end
  47.  
  48.  
  49. game.Players.PlayerAdded:Connect(function(Player)
  50.     MakePlayerImage(Player)
  51. end)
  52. for _, Player in pairs(game.Players:GetChildren()) do
  53.     MakePlayerImage(Player)  -- This is cause dosent rly activate PlayerAdded event on play testing
  54. end
  55.  
  56. -- Functions
  57.  
  58. function BroadCastMessage(Text, MessageDelayTime)
  59.     for i = 1,#Text,1 do
  60.         MessageValue.Value = string.sub(Text,1,i)
  61.         for _, L in pairs(MessageWaitSigns) do
  62.             if string.sub(Text,i,i) == L then
  63.                 wait(MessageWaitSignDelay)
  64.             end
  65.         end
  66.         wait(LetterInvertal)
  67.     end
  68.     if tonumber(MessageDelayTime) ~= nil then
  69.         wait(MessageDelayTime)
  70.     else
  71.         wait(DefaultMessageDelayTime)
  72.     end
  73. end
  74.  
  75. function HideCastMessage()
  76.     HideDialogueEvent:FireAllClients()
  77. end
  78.  
  79. function SetMessagePlayer(Name)
  80.     if Name == "Random" then
  81.         randomPlayer = game.Players:GetChildren()[math.random(1,#game.Players:GetChildren())]
  82.         Name = randomPlayer.Name
  83.     end
  84.     PlayerImageValue.Value = PlayerImages[Name]
  85.     PlayerNameValue.Value = Name
  86. end
  87.  
  88. function SetMessageSpeaker(Name, Model)
  89.     ImageValue.Value = Model
  90.     SpeakerValue.Value = Name
  91. end
  92.  
  93. function ChangeTime(ToTime, TweenDuration)
  94.     local Lightning = game.Lighting
  95.     local TI = TweenInfo.new(TweenDuration,Enum.EasingStyle.Linear)
  96.     local Tween = TweenService:Create(Lightning, TI, {ClockTime = ToTime})
  97.     Tween:Play()
  98. end
  99.  
  100. function ChangeFogend(ChangeTo, TweenDuration,ColourOrNone)
  101.     if ColourOrNone ~= 'None' then
  102.         game.Lighting.FogColor = ColourOrNone
  103.     end
  104.     local FogendValue = Instance.new('IntValue')
  105.     FogendValue.Value = game.Lighting.FogEnd
  106.     FogendValue:GetPropertyChangedSignal('Value'):Connect(function()
  107.         game.Lighting.FogEnd = FogendValue.Value
  108.     end)
  109.     local TI = TweenInfo.new(TweenDuration,Enum.EasingStyle.Linear)
  110.     local Tween = TweenService:Create(FogendValue, TI, {Value = ChangeTo})
  111.     Tween:Play()
  112.     spawn(function()
  113.         Tween.Completed:Connect(function()
  114.             FogendValue:Destroy()
  115.         end)
  116.     end)
  117. end
  118.  
  119. function teleportPlayers(partCFrame)
  120.     local players = game.Players:getPlayers()
  121.     for _,player in pairs(players) do
  122.         if player.Character then
  123.             if player.Character.HumanoidRootPart.Anchored == false then
  124.                 player.Character.Humanoid.Jump = true
  125.             end
  126.         end
  127.     end
  128.     wait(.5)
  129.     for _,player in pairs(players) do
  130.         if player.Character then
  131.             if player.Character.HumanoidRootPart.Anchored == false then
  132.                 player.Character:SetPrimaryPartCFrame(partCFrame)
  133.             end
  134.         end
  135.     end
  136. end
  137.  
  138. function TransitionScreen()
  139.     for _, player in pairs(game.Players:GetPlayers()) do
  140.         spawn(function()
  141.             local NewGui = game.ServerStorage.Assets.TransitionScreen:Clone()
  142.             NewGui.Parent = player.PlayerGui
  143.         end)
  144.     end
  145. end
  146.  
  147. --- MainScript ---
  148.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement