Advertisement
Sungmingamerpro13

MainScript (Script) with ViewportFrame

Feb 17th, 2024
1,232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 3.40 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. SpeakerEvent = game.ReplicatedStorage.Message.SpeakerEvent
  15. ObjectiveEvent = game.ReplicatedStorage.ObjectiveEvent
  16. HideObjectiveEvent = game.ReplicatedStorage.ObjectiveEvent.HideObjectiveEvent
  17. TimerEvent = game.ReplicatedStorage.TimerEvent
  18. HideTimerEvent = game.ReplicatedStorage.TimerEvent.HideTimerEvent
  19.  
  20. -- Setup Player Images
  21.  
  22. local randomCharacter
  23. local randomCharacterName
  24.  
  25. local function getRandomCharacter()
  26.    
  27.     local players = PlayerService:GetPlayers()
  28.    
  29.     repeat
  30.         local number = math.random(1, #players)
  31.         local randomPlayer = players[number]
  32.         randomCharacter = randomPlayer.Character
  33.     until randomCharacter
  34.    
  35.     randomCharacterName = randomCharacter.Name
  36.     randomCharacter.Archivable = true
  37.    
  38. end
  39.  
  40. -- Functions
  41.  
  42.  
  43. function BroadcastMessage(Text, MessageDelayTime)
  44.     -- This makes the message appear like a typewriter
  45.     for i = 1,#Text,1 do
  46.         MessageValue.Value = string.sub(Text,1,i)
  47.         for _, L in pairs(MessageWaitSigns) do
  48.             if string.sub(Text,i,i) == L then
  49.                 wait(MessageWaitSignDelay)
  50.             end
  51.         end
  52.         wait(LetterInvertal)
  53.     end
  54.     if tonumber(MessageDelayTime) ~= nil then
  55.         wait(MessageDelayTime)
  56.     else
  57.         wait(DefaultMessageDelayTime)
  58.     end
  59.     MessageValue.Value = 'None'
  60.     return true
  61. end
  62.  
  63. function ChangeTime(ToTime, TweenDuration)
  64.     local Lightning = game.Lighting
  65.     local TI = TweenInfo.new(TweenDuration,Enum.EasingStyle.Linear)
  66.     local Tween = TweenService:Create(Lightning, TI, {ClockTime = ToTime})
  67.     Tween:Play()
  68. end
  69.  
  70. function ChangeFogend(ChangeTo, TweenDuration,ColourOrNone)
  71.     if ColourOrNone ~= 'None' then
  72.         game.Lighting.FogColor = ColourOrNone
  73.     end
  74.     local FogendValue = Instance.new('IntValue')
  75.     FogendValue.Value = game.Lighting.FogEnd
  76.     FogendValue:GetPropertyChangedSignal('Value'):Connect(function()
  77.         game.Lighting.FogEnd = FogendValue.Value
  78.     end)
  79.     local TI = TweenInfo.new(TweenDuration,Enum.EasingStyle.Linear)
  80.     local Tween = TweenService:Create(FogendValue, TI, {Value = ChangeTo})
  81.     Tween:Play()
  82.     spawn(function()
  83.         Tween.Completed:Connect(function()
  84.             FogendValue:Destroy()
  85.         end)
  86.     end)
  87. end
  88.  
  89. function teleportPlayers(partCFrame)
  90.     local players = game.Players:getPlayers()
  91.     for _,player in pairs(players) do
  92.         if player.Character then
  93.             if player.Character.HumanoidRootPart.Anchored == false then
  94.                 player.Character.Humanoid.Jump = true
  95.             end
  96.         end
  97.     end
  98.     wait(.5)
  99.     for _,player in pairs(players) do
  100.         if player.Character then
  101.             if player.Character.HumanoidRootPart.Anchored == false then
  102.                 player.Character:SetPrimaryPartCFrame(partCFrame)
  103.             end
  104.         end
  105.     end
  106. end
  107.  
  108. function SetObjectives(Objective)
  109.     ObjectiveEvent:FireAllClients(Objective)
  110. end
  111.  
  112. function ClearObjectives()
  113.     HideObjectiveEvent:FireAllClients()
  114. end
  115.  
  116. function TopText(Text, Time)
  117.     for i = Time,0,-1 do
  118.         TimerEvent:FireAllClients(Text.." ("..i..")")
  119.         wait(1)
  120.     end
  121.     HideTimerEvent:FireAllClients()
  122. end
  123.  
  124. function TransitionScreen()
  125.     for _, player in pairs(game.Players:GetChildren()) do
  126.         spawn(function()
  127.             local NewGui = game.ServerStorage.Assets.TransitionScreen:Clone()
  128.             NewGui.Parent = player.PlayerGui
  129.         end)
  130.     end
  131. end
  132.  
  133. --- MainScript of Story ---
  134.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement