Advertisement
Sungmingamerpro13

MainScript(Horror Friends)

Feb 26th, 2023
821
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 5.59 KB | None | 1 0
  1. -- Services
  2. PlayerService = game:GetService('Players')
  3. TweenService = game:GetService('TweenService')
  4. TeleportService = game:GetService("TeleportService")
  5.  
  6. -- Variables
  7.  
  8. DefaultMessageDelayTime = 4
  9. LetterInvertal = 0.05
  10. MessageWaitSigns = {',', '?', '.'}
  11. MessageWaitSignDelay = 1
  12.  
  13. local NightStatus = game.ReplicatedStorage.NightStatus
  14. local ObjectiveValue = game.ReplicatedStorage.Objective
  15. local Status = game.ReplicatedStorage.Status
  16. local MessageValue = game.ReplicatedStorage.Message
  17. local ImageValue = game.ReplicatedStorage.Message.SpeakerImage
  18. local SpeakerNameValue = game.ReplicatedStorage.Message.SpeakerName
  19. local Cutscene1 = game.ReplicatedStorage.CutscenesEvent.Cutscene
  20. local TeleportPoints = game.Workspace.TeleportPoints
  21. local TransitionEvent = game.ReplicatedStorage.TransitionEvent
  22.  
  23. -- Setup Player Images
  24.  
  25. local RandomPlayer
  26.  
  27. PlayerImages = {}
  28.  
  29.  
  30. function MakePlayerImage(Player)
  31.     local Image = ''
  32.     local Success,Error = pcall(function()
  33.         local ID = PlayerService:GetUserIdFromNameAsync(Player.Name)or ''
  34.         local PlayerImage, IsReady = PlayerService:GetUserThumbnailAsync(ID, Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size420x420)
  35.         if IsReady == true then
  36.             -- Ready to use image
  37.             Image = tostring(PlayerImage)
  38.         else
  39.             -- Use alternative picture
  40.             Image = ("http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=%s"):format(Player.Name)
  41.         end
  42.     end)
  43.     if Success == true then
  44.         -- Successful
  45.     else
  46.         Image = ("http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=%s"):format(Player.Name)
  47.     end
  48.     PlayerImages[Player.Name] = Image
  49. end
  50.  
  51.  
  52. game.Players.PlayerAdded:Connect(function(Player)
  53.     MakePlayerImage(Player)
  54. end)
  55. for _, Player in pairs(game.Players:GetChildren()) do
  56.     MakePlayerImage(Player)  -- This is cause dosent rly activate PlayerAdded event on play testing
  57. end
  58.  
  59.  
  60.  
  61. -- Functions
  62.  
  63.  
  64. function BroadcastMessage(Text, MessageDelayTime)
  65.     -- This makes the message appear like a typewriter
  66.     for i = 1,#Text,1 do
  67.         MessageValue.Value = string.sub(Text,1,i)
  68.         for _, L in pairs(MessageWaitSigns) do
  69.             if string.sub(Text,i,i) == L then
  70.                 wait(MessageWaitSignDelay)
  71.             end
  72.         end
  73.         wait(LetterInvertal)
  74.     end
  75.     if tonumber(MessageDelayTime) ~= nil then
  76.         wait(MessageDelayTime)
  77.     else
  78.         wait(DefaultMessageDelayTime)
  79.     end
  80.     MessageValue.Value = 'None'
  81.     return true
  82. end
  83.  
  84.  
  85.  
  86. function SetMessageSpeaker(Name)
  87.     if Name == "Random" then
  88.         RandomPlayer = game.Players:GetChildren()[math.random(1,#game.Players:GetChildren())]
  89.         Name = RandomPlayer.Name
  90.     end
  91.     ImageValue.Value = PlayerImages[Name] or 'rbxassetid://12325724267'
  92.     SpeakerNameValue.Value = Name
  93. end
  94.  
  95. function SetMessageSpeaker2(Name)
  96.     ImageValue.Value = 'rbxassetid://12328732473'
  97.     SpeakerNameValue.Value = Name
  98. end
  99.  
  100. function ChangeTime(ToTime, TweenDuration)
  101.     local Lightning = game.Lighting
  102.     local TI = TweenInfo.new(TweenDuration,Enum.EasingStyle.Linear)
  103.     local Tween = TweenService:Create(Lightning, TI, {ClockTime = ToTime})
  104.     Tween:Play()
  105. end
  106.  
  107. function ChangeFogend(ChangeTo, TweenDuration,ColourOrNone)
  108.     if ColourOrNone ~= 'None' then
  109.         game.Lighting.FogColor = ColourOrNone
  110.     end
  111.     local FogendValue = Instance.new('IntValue')
  112.     FogendValue.Value = game.Lighting.FogEnd
  113.     FogendValue:GetPropertyChangedSignal('Value'):Connect(function()
  114.         game.Lighting.FogEnd = FogendValue.Value
  115.     end)
  116.     local TI = TweenInfo.new(TweenDuration,Enum.EasingStyle.Linear)
  117.     local Tween = TweenService:Create(FogendValue, TI, {Value = ChangeTo})
  118.     Tween:Play()
  119.     spawn(function()
  120.         Tween.Completed:Connect(function()
  121.             FogendValue:Destroy()
  122.         end)
  123.     end)
  124. end
  125.  
  126. function teleportPlayers(partCFrame)
  127.     local players = game.Players:getPlayers()
  128.     for _,player in pairs(players) do
  129.         if player.Character then
  130.             if player.Character.HumanoidRootPart.Anchored == false then
  131.                 player.Character.Humanoid.Jump = true
  132.             end
  133.         end
  134.     end
  135.     wait(.5)
  136.     for _,player in pairs(players) do
  137.         if player.Character then
  138.             if player.Character.HumanoidRootPart.Anchored == false then
  139.                 player.Character:SetPrimaryPartCFrame(partCFrame)
  140.             end
  141.         end
  142.     end
  143. end
  144.  
  145. function TopStatus(number)
  146.     for i = number, 0, -1 do
  147.         Status.Value = "Waiting For Players("..i..")"
  148.         wait(1)
  149.     end
  150.     Status.Value = "None"
  151. end
  152.  
  153. function SetObjective(Text)
  154.     ObjectiveValue.Value = Text
  155. end
  156.  
  157. function ClearObjective()
  158.     ObjectiveValue.Value = "None"
  159. end
  160.  
  161. function ChapterComplete()
  162.     for _, player in pairs(game.Players:GetPlayers()) do
  163.         spawn(function()
  164.             local NewGui = game.ServerStorage:WaitForChild("Assets"):FindFirstChild("ChapterComplete"):Clone()
  165.             NewGui.Parent = player.PlayerGui
  166.             wait(5)
  167.             local TeleportData = {
  168.                 AddWins = true,
  169.                 PlayerName = player.UserId
  170.             }
  171.             player.Coins.Value = player.Coins.Value + 100
  172.             player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
  173.             TeleportService:Teleport(11258969850, player, TeleportData)
  174.         end)
  175.     end
  176. end
  177.  
  178. function AddCoins(AddCoin)
  179.     for i, v in pairs(game.Players:GetPlayers()) do
  180.         spawn(function()
  181.             v.Coins.Value += AddCoin
  182.         end)
  183.     end
  184. end
  185.  
  186. -- MainScript --
  187.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement