Advertisement
Guest User

BYC Reborn Server

a guest
Jun 29th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 42.79 KB | None | 0 0
  1. --Declearations
  2. local studio = game.JobId == ""
  3. local PermissionTracking = {}
  4. local resetgarageinfo = {}
  5. local garageinfo = {}
  6. local collisionInformation = {}
  7. local Players = {}
  8. local soundLibrary = game.ServerStorage.GameSounds
  9. game.StarterGui.ResetPlayerGuiOnSpawn = false
  10. local RCSIC = game.Players.CSConnections
  11. local market = game:GetService("MarketplaceService")
  12. local http = game:GetService("HttpService")
  13. local datastore = game:GetService("DataStoreService")
  14. local compression = require(game.ServerScriptService.CompressionService)
  15. local gmod = require(workspace.GlobalModule)
  16. local IdentifyClass = gmod.identifyClass1
  17. local IdentifyClass2 = gmod.identifyClass2
  18. local placeIds = {
  19.     ["Public Server"] = gmod.placeIds.public;
  20.     ["Test Server"] = gmod.placeIds.test;
  21.     ["Player Hub"] = gmod.placeIds.hub;
  22.     ["Exclusive Server"] = gmod.placeIds.pro;
  23. }
  24. local garageconnections = { g1 = {}; g2 = {}; g3 = {}; g4 = {}; g5 = {}; g6 = {}; g7 = {}; g8 = {} }
  25. local PartLimits = gmod.PartSettings
  26. local DurabilityMultiplier = gmod.DurabilityMultiplier
  27. local Names = gmod.PartNames
  28. local serverName
  29. local servertype
  30. local user
  31. local pass
  32.  
  33. local PartInfo = gmod.PartInfo
  34.  
  35. _G.rotateModel = function(model,center,rotation)
  36.     local parts ={}
  37.     local function scan(parent)
  38.         for _,obj in pairs(parent:GetChildren()) do
  39.             if (obj:IsA("BasePart")) then
  40.                 table.insert(parts,obj)
  41.             end
  42.             scan(obj)
  43.         end
  44.     end
  45.     scan(model)
  46.     for _,part in pairs(parts) do
  47.         part.CFrame = (center*rotation*(center:inverse()*part.CFrame))
  48.     end
  49. end
  50.  
  51. _G.Iterate = function(func,start)
  52.     for _,w in pairs(start:GetChildren()) do
  53.         func(w)
  54.         _G.Iterate(func,w)
  55.     end
  56. end
  57.  
  58. _G.Iterate(function(w)
  59.     if w:IsA("BasePart") then
  60.         w.Locked = true
  61.     end
  62. end,
  63. workspace.Map) --lock all instances
  64.  
  65. --if not studio then serverName = http:JSONDecode(http:GetAsync("http://api.robloxapi.com/Assets/AssetInfo?AssetId="..game.PlaceId)).Name end
  66.  
  67. serverName = "Public Server"
  68. ----------------------------
  69. -- Private Server Handler --
  70. ----------------------------
  71. print([[Running "Private Server Handler"]])
  72. print("Successful Run:",pcall(function()
  73.     for i,v in pairs(placeIds) do
  74.         if v == game.PlaceId then
  75.             servertype = i
  76.         end
  77.     end
  78.     if not servertype then
  79.         servertype = "Private Server"
  80.         local scope = game:GetService("DataStoreService"):GetDataStore("HUB","PRIVATE_SERVER_METADATA")
  81.         local info = http:JSONDecode(scope:GetAsync(serverName))
  82.         user = serverName
  83.         pass = info.password
  84.         local function update()
  85.             scope:UpdateAsync(serverName,function(oldval)
  86.                 oldval = http:JSONDecode(oldval)
  87.                 oldval.playerCount = game.Players.NumPlayers
  88.                 if game.Players.NumPlayers == 0 then
  89.                     oldval.active = false
  90.                 else
  91.                     oldval.active = true
  92.                 end
  93.                 return http:JSONEncode(oldval)
  94.             end)
  95.         end
  96.         game.Players.PlayerAdded:connect(update)
  97.         game.Players.PlayerRemoving:connect(update)
  98.         game.ServerScriptService.SaveManager.ServerName.Value = serverName
  99.     end
  100. end))
  101. ----------------------------
  102.  
  103. --------------------------------
  104. -- Physical Environment Setup --
  105. --------------------------------
  106. print([[Running "Physical Environment Setup"]])
  107. for i = 1,8 do
  108.     local garage = workspace.Map.Garages.Garages["Garage"..i]
  109.     local size = garage:GetExtentsSize()
  110.     local pos = garage:GetModelCFrame().p
  111.    
  112.     gmod:refreshSampleParts(i)
  113.    
  114.     collisionInformation["Garage"..i] = {
  115.         xs = pos.x - size.x/2;
  116.         xf = pos.x + size.x/2;
  117.         ys = pos.y - size.y/2;
  118.         yf = pos.y + size.y/2;
  119.         zs = pos.z - size.z/2;
  120.         zf = pos.z + size.z/2;
  121.     }
  122.    
  123.     garageinfo["Garage"..i] = {
  124.         size = size;
  125.         pos = garage:GetModelCFrame();
  126.     }
  127.    
  128.     resetgarageinfo["Garage"..i] = {
  129.         doorinfo = {
  130.             size = garage.Door.Size;
  131.             cframe = garage.Door.CFrame;
  132.             transparency = 0;
  133.         };
  134.         ceilinginfo = {
  135.             cframe = garage.Top.CFrame;
  136.             transparency = 0;
  137.         };
  138.         motordirectory = garage.Motors
  139.     }
  140.    
  141.     garage.Top.ChildAdded:connect(function(child)
  142.         if child:IsA("Sound") then
  143.             child.TimePosition = .2
  144.         end
  145.     end)
  146.    
  147.     local floorLight = gmod.new("SurfaceLight",{
  148.         Name = "FloorLight";
  149.         Brightness = 0;
  150.         Face = "Top";
  151.         Range = 0;
  152.         Shadows = true;
  153.         Parent = garage.Bottom
  154.     })
  155.    
  156.     game.Lighting.Changed:connect(function(prop)
  157.         if prop ~= "TimeOfDay" then return end
  158.         local minutes = game.Lighting:GetMinutesAfterMidnight()
  159.         local exitPhaseStart, exitPhaseEnd = 360, 420
  160.         local enterPhaseStart, enterPhaseEnd = 1080, 1140
  161.        
  162.         if minutes >= enterPhaseStart or minutes <= exitPhaseEnd then
  163.             floorLight.Enabled = true
  164.             if minutes >= enterPhaseEnd or minutes <= exitPhaseStart then
  165.                 floorLight.Brightness = .5
  166.                 floorLight.Range = 60
  167.             end
  168.         else
  169.             floorLight.Enabled = false
  170.         end
  171.        
  172.         if minutes >= enterPhaseStart and minutes <= enterPhaseEnd then
  173.             local scale = (minutes - enterPhaseStart)/(enterPhaseEnd - enterPhaseStart)
  174.             floorLight.Brightness = scale * .5
  175.             floorLight.Range = scale * 60
  176.         elseif minutes >= exitPhaseStart and minutes <= exitPhaseEnd then
  177.             local scale = 1 - (minutes - exitPhaseStart)/(exitPhaseEnd - exitPhaseStart)
  178.             floorLight.Brightness = scale * .5
  179.             floorLight.Range = scale * 60
  180.         end
  181.     end)
  182. end
  183.  
  184. setmetatable(resetgarageinfo,{
  185.     __call = function(igi,number)
  186.         local info = igi["Garage"..number]
  187.         local garage = workspace.Map.Garages.Garages["Garage"..number]
  188.        
  189.         garage.Door.Size = info.doorinfo.size
  190.         garage.Door.CFrame = info.doorinfo.cframe
  191.         garage.Door.Transparency = info.doorinfo.transparency
  192.        
  193.         garage.Top.CFrame = info.ceilinginfo.cframe
  194.         garage.Top.Transparency = info.ceilinginfo.transparency
  195.        
  196.         for _,w in pairs(info.motordirectory:GetChildren()) do
  197.             w.C0 = CFrame.new(w.C0.p)
  198.         end
  199.     end
  200. })
  201.  
  202. game.Lighting:SetMinutesAfterMidnight(os.time()%1440)
  203. spawn(function() while wait(.25) do game.Lighting:SetMinutesAfterMidnight(game.Lighting:GetMinutesAfterMidnight() + .25) end end)
  204. spawn(function() while wait(1) do game.ReplicatedStorage.PhysicalData.ServerUpTime.Value = game.ReplicatedStorage.PhysicalData.ServerUpTime.Value + 1 end end)
  205.  
  206. local MotorFunctions = {}
  207. spawn(function()
  208.     for _,w in pairs(workspace.Map.Garages.Garages:GetChildren()) do
  209.         local GarageMotorFunctions = {}
  210.         w.Back:BreakJoints()
  211.         local weld = Instance.new("Motor",w.Motors)
  212.         weld.Name = "Back"
  213.         weld.Part0 = w.Back
  214.         weld.Part1 = w.Bottom
  215.         weld.C1 = CFrame.fromEulerAnglesXYZ(0,0,0) * CFrame.new(0,0,-w.Bottom.Size.Z/2 - w.Back.Size.Z/2)
  216.         weld.C0 = CFrame.new(0,-w.Back.Size.Y/2 + w.Bottom.Size.Y/2,0)
  217.         w.Back.Anchored = false
  218.         GarageMotorFunctions[weld.Name] = { motor = weld , invoked = 0}
  219.         MotorFunctions[w.Name] = GarageMotorFunctions
  220.        
  221.         local part = w.Back:Clone()
  222.         part.Parent = w
  223.         part:ClearAllChildren()
  224.         part.Name = "BackwardsCollision"
  225.         part.Transparency = 1
  226.         part.Anchored = true
  227.         part.CFrame = weld.C0:toWorldSpace(CFrame.new())
  228.        
  229.         w.Back.Changed:connect(function() weld.C0:toWorldSpace(CFrame.new()) end)
  230.     end
  231. end)
  232. --------------------------------
  233.  
  234. -----------------------------
  235. -- Miscellaneous Functions --
  236. -----------------------------
  237. print([[Running "Miscellaneous Functions"]])
  238. function GetParts(plr,teamfilter,ingarage,class)
  239.     local PartsCollected = {}
  240.     for _,w in pairs(workspace:GetChildren()) do
  241.         if w:IsA("BasePart") then
  242.             local incorrect = false
  243.             if teamfilter then if tonumber(string.sub(w.Name,1,1)) ~= teamfilter then incorrect = true end end
  244.             if ingarage then
  245.                 local cInfo = collisionInformation["Garage"..ingarage]
  246.                 local pos = w.Position
  247.                 if pos.x > cInfo.xs and pos.x < cInfo.xf and pos.y > cInfo.ys and pos.y < cInfo.yf and pos.z > cInfo.zs and pos.z < cInfo.zf then else incorrect = true end
  248.             end
  249.             if class then
  250.                 if not IdentifyClass[class](w) then incorrect = true end
  251.             end
  252.             if not incorrect then table.insert(PartsCollected,w) end
  253.         end
  254.     end
  255.     return PartsCollected
  256. end
  257.  
  258. function returnLocationIGUP(pos,critical)
  259.     local garage,numDone = false,0
  260.     for i = 1,8 do
  261.         spawn(function()
  262.             local cInfo = collisionInformation["Garage"..i]
  263.             local direct = workspace.Map.Garages.Garages["Garage"..i]
  264.             if
  265.                 pos.x > cInfo.xs + (critical and direct.L.Size.X or 3) and
  266.                 pos.x < cInfo.xf - (critical and direct.R.Size.X or 3) and
  267.                 pos.y > cInfo.ys + (critical and direct.Bottom.Size.Y or 3) and
  268.                 pos.y < cInfo.yf - (critical and direct.Top.Size.Y or 3) and
  269.                 pos.z > cInfo.zs + (critical and direct.Door.Size.Z or 3) and
  270.                 pos.z < cInfo.zf - (critical and direct.Back.Size.Z + 6 or 3) then
  271.                 garage = i
  272.             end
  273.             numDone = numDone + 1
  274.         end)
  275.     end
  276.     repeat wait() until numDone == 8
  277.     return garage
  278. end
  279.  
  280. function getUsernameFromId(ID)
  281.     for _,v in pairs(game:GetService("InsertService"):GetUserSets(ID)) do
  282.         if v.Name == "My Models" then return v.CreatorName end
  283.     end
  284. end
  285.  
  286. function clearConnections(tabl)
  287.     for _,w in pairs(tabl) do
  288.         w:disconnect()
  289.     end
  290. end
  291.  
  292. SpecialFunctions = {
  293.     RequestTeleport = function(sent,plr,reciever)
  294.         local tele = game.ReplicatedStorage.Miscellaneous.Teleport:Clone()
  295.         tele.MouseButton1Click:connect(function()
  296.             sent:remove()
  297.             if reciever.Character then reciever.Character:MoveTo(plr.Character:GetModelCFrame().p) RCSIC.EventFired:FireClient(reciever,"Summoned") end
  298.         end)
  299.         tele.Parent = sent.ButtonSpace
  300.         spawn(function()
  301.             wait(10)
  302.             if sent and sent.Parent then sent:remove() end
  303.         end)
  304.     end
  305. }
  306. -----------------------------
  307.  
  308. -------------------------------------------------------
  309. -- Remote Client-Server Interaction Connection Setup --
  310. -------------------------------------------------------
  311. print([[Running "Remote Client-Server Interaction Connection Setup"]])
  312. function IsInGarage(sender,Gnum,plr)
  313.     if not Gnum then return end
  314.     if game.ReplicatedStorage.GarageDetection["Garage"..Gnum]:findFirstChild(plr and plr.Name or sender.Name) then return true else return false end
  315. end
  316.  
  317. function FireMotor(plr,motor,direction,garage)
  318.     local mt = MotorFunctions["Garage"..(garage or plr.PlayerGui.Team.Value)][motor]
  319.     mt.invoked = mt.invoked + 1
  320.     local __invoked = mt.invoked
  321.     local s = Instance.new("Sound",mt.motor.Part0)
  322.     s.SoundId = direction and "rbxassetid://142643714" or "rbxassetid://142643742"
  323.     s.Pitch = 1
  324.     s.Volume = .2
  325.     s:Play()
  326.     local opt = 0
  327.     local algorithm = math.abs((direction and (mt.motor.Part0.Rotation.X - 90) or - mt.motor.Part0.Rotation.X))
  328.     for i = 1,algorithm do
  329.         if mt.invoked ~= __invoked then break end
  330.         opt = opt + 1
  331.         mt.motor.C0 = mt.motor.C0 * CFrame.fromEulerAnglesXYZ(math.rad(direction and 1 or -1),0,0)
  332.         wait()
  333.     end
  334.     if opt == math.floor(algorithm) then mt.motor.C0 = CFrame.new(mt.motor.C0.x,mt.motor.C0.y,mt.motor.C0.z) * CFrame.Angles(math.rad(direction and 90 or 0),0,0) else s:Stop() end
  335.     if opt < 80 then s:Stop() end
  336.     s:remove()
  337. end
  338.  
  339. function GetGarageParts()
  340.     local parts = game.ServerStorage.Parts.Parts:Clone()
  341.     parts.Parent = game.ReplicatedStorage
  342.     return parts
  343. end
  344.  
  345. function SetPermissions(sender,player,tableofpermissions)
  346.     PermissionTracking[sender.PlayerGui.Team.Value][player.PlayerGui.Team.Value] = tableofpermissions
  347.     game.Players.CSConnections.BlockPlayer:FireClient(player,sender.PlayerGui.Team.Value,tableofpermissions.blockplayer and true or false)
  348.     if not tableofpermissions.enableforcefield and game.ReplicatedStorage.GarageDetection["Garage"..sender.PlayerGui.Team.Value]:findFirstChild(player.Name) then
  349.         if player.Character:findFirstChild("ForceField") then player.Character.ForceField:remove() end
  350.     end
  351.     if not tableofpermissions.enablebuildingtools and game.ReplicatedStorage.GarageDetection["Garage"..sender.PlayerGui.Team.Value]:findFirstChild(player.Name) then
  352.         RCSIC.SafteyPlayer:FireClient(player,true)
  353.     end
  354.     if tableofpermissions.blockplayer then
  355.         local gnum = sender.PlayerGui.Team.Value
  356.         if game.ReplicatedStorage.GarageDetection["Garage"..gnum]:findFirstChild(player.Name) then
  357.             player:LoadCharacter()
  358.         end
  359.         garageconnections["g"..gnum][player.Name] = game.ReplicatedStorage.GarageDetection["Garage"..gnum].ChildAdded:connect(function(child)
  360.             if child.Value == player then player:LoadCharacter() end
  361.         end)
  362.     else
  363.         local gnum = sender.PlayerGui.Team.Value
  364.         if garageconnections["g"..gnum][player.Name] then garageconnections["g"..gnum][player.Name]:disconnect() garageconnections["g"..gnum][player.Name] = nil end
  365.     end
  366. end
  367.  
  368. function GetPermissions(sender,player,reverse)
  369.     return reverse and PermissionTracking[player.PlayerGui.Team.Value][sender.PlayerGui.Team.Value] or PermissionTracking[sender.PlayerGui.Team.Value][player.PlayerGui.Team.Value]
  370. end
  371.  
  372. function LoadCharacter(sender,requested)
  373.     if not requested then sender:LoadCharacter() else requested:LoadCharacter() end
  374. end
  375.  
  376. function GetPlayerFromGarage(sender,gnum)
  377.     for _,w in pairs(game.Players:GetPlayers()) do
  378.         if w.PlayerGui.Team.Value == tonumber(gnum) then return w end
  379.     end
  380. end
  381.  
  382. function GetGarageFromPlayer(sender,search)
  383.     if search then
  384.         local find = game.ReplicatedStorage.GarageDetection:findFirstChild(search.Name,true)
  385.         if find then return string.sub(find.Parent.Name,string.len("Garage") + 1) end
  386.     else
  387.         local find = game.ReplicatedStorage.GarageDetection:findFirstChild(sender.Name,true)
  388.         if find then return string.sub(find.Parent.Name,string.len("Garage") + 1) end
  389.     end
  390. end
  391.  
  392. function SendNotification(sender,reciever,desc,special)
  393.     local note = game.ServerStorage.Notification:Clone()
  394.     note.Parent = reciever
  395.     note.Description.Text = desc
  396.     note.SenderImgUrl.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&format=png&username="..sender.Name
  397.     note.Exit.MouseButton1Click:connect(function()
  398.         note:remove()
  399.     end)
  400.     RCSIC.SendNotification:FireClient(reciever,note)
  401.     if special then SpecialFunctions[special](note,sender,reciever) end
  402. end
  403.  
  404. function HasPass(plr,id,player)
  405.     return game:GetService("GamePassService"):PlayerHasPass(player or plr, id)
  406. end
  407.  
  408. function PromptOrderInfo(plr,assetId,parent,assetType,tax)
  409.     local gui = game.ServerStorage.TransactionManager:Clone()
  410.     local info = market:GetProductInfo(assetId,assetType == "DevProduct" and "Product" or "Asset")
  411.     gui.ProductInfo.Item.Value.Text = info.Name
  412.     gui.ProductInfo.User.Value.Text = plr.userId
  413.     gui.ProductInfo.Asset.Value.Text = assetType
  414.     gui.ProductInfo.SubTotal.Value.Text = "R$"..(info.PriceInRobux ~= "null" and info.PriceInRobux or "0")..".00"
  415.     gui.ProductInfo.Tax.Value.Text = "R$"..(tax and "2" or "0")..".00"
  416.     gui.ProductInfo.Total.Value.Text = "R$"..((info.PriceInRobux ~= "null" and info.PriceInRobux or 0) + (tax and 2 or 0))..".00"
  417.    
  418.     local sizeC = gui.Size
  419.     local posC = gui.Position
  420.    
  421.     gui.Size = UDim2.new(sizeC.X.Scale,0,0,0)
  422.     gui.Position = UDim2.new(posC.X.Scale,0,posC.Y.Scale + sizeC.Y.Scale/2,0)
  423.     gui.Parent = parent or plr.PlayerGui.Interface
  424.     gui:TweenSizeAndPosition(sizeC,posC,"Out","Linear",.2,true)
  425.     return gui
  426. end
  427.  
  428. function PromptSystemWarning(plr,msg)
  429.     local gui = game.ServerStorage.SystemWarning:Clone()
  430.     gui.MsgFrame.Msg.Text = msg
  431.    
  432.     local fr = gui.MsgFrame
  433.     local bc = fr.Back
  434.     local msgBox = fr.Msg
  435.     local title = fr.Title
  436.    
  437.     bc.MouseEnter:connect(function() bc.ImageColor3 = Color3.new(.25,.25,.25) end)
  438.     bc.MouseLeave:connect(function() bc.ImageColor3 = Color3.new(  0,  0,  0) end)
  439.    
  440.     bc.MouseButton1Down:connect(function() bc.ImageColor3 = Color3.new(.25,.25,.25) end)
  441.     bc.MouseButton1Up:connect  (function() bc.ImageColor3 = Color3.new(  0,  0,  0) end)
  442.    
  443.     gui.BackgroundTransparency = 1
  444.     fr.BackgroundTransparency = 1
  445.     bc.ImageTransparency = 1
  446.     msgBox.TextTransparency = 1
  447.     title.TextTransparency = 1
  448.     title.TextStrokeTransparency = 1
  449.    
  450.     gui.Parent = plr.PlayerGui.Interface
  451.    
  452.     for i = 1,0,-.1 do
  453.         gui.BackgroundTransparency = .25 + .75 * i
  454.         fr.BackgroundTransparency = i
  455.         bc.ImageTransparency = i
  456.         msgBox.TextTransparency = i
  457.         title.TextTransparency = i
  458.         title.TextStrokeTransparency = i
  459.         wait()
  460.     end
  461.     local removemsg
  462.     removemsg = bc.MouseButton1Click:connect(function()
  463.         removemsg:disconnect()
  464.         for i = 0,1,.1 do
  465.             gui.BackgroundTransparency = .25 + .75 * i
  466.             fr.BackgroundTransparency = i
  467.             bc.ImageTransparency = i
  468.             msgBox.TextTransparency = i
  469.             title.TextTransparency = i
  470.             title.TextStrokeTransparency = i
  471.             wait()
  472.         end
  473.         gui:remove()
  474.     end)
  475. end
  476.  
  477. function SelectModel(plr,parts,color)
  478.     local bound = Instance.new("Model",plr.PlayerGui)
  479.     for _,w in pairs(parts) do
  480.         local sb = Instance.new("SelectionBox",bound)
  481.         sb.Color = color
  482.         sb.Adornee = w
  483.     end
  484.     return bound
  485. end
  486.  
  487. function IdentifyPart(plr,part)
  488.     for _,w in pairs(IdentifyClass2) do
  489.         local n = w(part)
  490.         if n then return n end
  491.     end
  492.     return "P"
  493. end
  494.  
  495. function PerformCSMethod(plr,method,...)
  496.     return require(game.ServerScriptService.CompressionService)[method](require(game.ServerScriptService.CompressionService),...)
  497. end
  498.  
  499. function GetClosestPlayer(plr,vector)
  500.     local closestplayer,mag = nil,math.huge
  501.     if plr.Character then
  502.         for _,w in pairs(game.Players:GetPlayers()) do
  503.             if w ~= plr then
  504.                 if w.Character then
  505.                     local distance = (w.Character:GetModelCFrame().p - (vector and vector or plr.Character:GetModelCFrame().p)).magnitude
  506.                     if distance < mag then closestplayer = w; mag = distance end
  507.                 end
  508.             end
  509.         end
  510.     end
  511.    
  512.     return closestplayer,mag
  513. end
  514.  
  515. function GetClosestEFP(plr,vector)
  516.     local closestefp,mag = nil,math.huge
  517.     if plr.Character then
  518.         for _,w in pairs(workspace:GetChildren()) do
  519.             if string.sub(w.Name,1,1) ~= tostring(plr.PlayerGui.Team.Value) and string.sub(w.Name,2,2) == "F" and w:IsA("BasePart") then
  520.                 local distance = (w.Position - (vector and vector or plr.Character:GetModelCFrame().p)).magnitude
  521.                 if distance < mag then closestefp = w; mag = distance end
  522.             end
  523.         end
  524.     end
  525.    
  526.     return closestefp,mag
  527. end
  528.  
  529. function CreateReticle(plr,parts,parent)
  530.     if type(parts) == "userdata" then
  531.         local reticle = game.ServerStorage.Reticle:Clone()
  532.         reticle.Parent = parent
  533.         reticle.Adornee = parts
  534.         spawn(function()
  535.             while reticle and reticle.Parent do
  536.                 reticle.Overlay.ROverlay2.Rotation = reticle.Overlay.ROverlay2.Rotation + 5
  537.                 wait()
  538.             end
  539.         end)
  540.         return reticle
  541.     elseif type(parts) == "table" then
  542.         local reticles = {}
  543.         for _,w in pairs(parts) do
  544.             spawn(function()
  545.                 local reticle = game.ServerStorage.Reticle:Clone()
  546.                 reticle.Parent = parent
  547.                 reticle.Adornee = w
  548.                 table.insert(reticles,reticle)
  549.                 while reticle and reticle.Parent do
  550.                     reticle.Overlay.ROverlay2.Rotation = reticle.Overlay.ROverlay2.Rotation + 5
  551.                     wait()
  552.                 end
  553.             end)
  554.         end
  555.         repeat wait() until #reticles == #parts
  556.         return reticles
  557.     end
  558. end
  559.  
  560. function returnLocationIG(plr,pos,critical)
  561.     return returnLocationIGUP(pos,critical)
  562. end
  563.  
  564. function createGBoundingBox(plr,garage)
  565.     local info = garageinfo["Garage"..(garage or plr.PlayerGui.Team.Value)]
  566.     local box = Instance.new("Part",game.ReplicatedStorage)
  567.     box.FormFactor = "Custom"
  568.     box.Name = "ooo"
  569.     box.Anchored = true
  570.     box.CanCollide = false
  571.     box.Transparency = 1
  572.     box.BrickColor = BrickColor.White()
  573.     box.Size = info.size
  574.     box.CFrame = info.pos
  575.     return box,info.pos
  576. end
  577.  
  578. function getGarageInfo(plr,garage)
  579.     return garageinfo["Garage"..garage]
  580. end
  581.  
  582. function getDataComplexity(plr,requested)
  583.     return game.Players[requested and requested.Name or plr.Name].DataComplexity
  584. end
  585.  
  586. function PromptSystemHint(plr,displayMsg,lifetime)
  587.     local hint = game.ServerStorage.SystemHint:Clone()
  588.     hint.Prompt.Text = getUsernameFromId(39563808)..": "..displayMsg
  589.     hint.Prompt.Position = UDim2.new(0,0,1,20)
  590.     hint.Parent = plr.PlayerGui:WaitForChild("Interface")
  591.     hint.Prompt:TweenPosition(UDim2.new(0,0,1,0),"Out","Quad",.2,true,function()
  592.         wait(lifetime or 3)
  593.         hint.Prompt:TweenPosition(UDim2.new(0,0,1,20),"Out","Quad",.2,true,function()
  594.             hint:remove()
  595.         end)
  596.     end)
  597. end
  598.  
  599. function FireMissile(plr,w,lifetime)
  600.     local MSPE = game.ServerStorage.MissileSmokeParticleEmitter:Clone()
  601.     local function PreserveParticles()
  602.         MSPE.Enabled = false
  603.         MSPE.Parent = workspace.MissileParticleContainer
  604.         spawn(function()
  605.             wait(20)
  606.             MSPE:remove()
  607.         end)
  608.     end
  609.    
  610.     local team = plr.PlayerGui.Team.Value
  611.     if w.Fire.Enabled == false and not w:findFirstChild("Abort") then
  612.         w:BreakJoints()
  613.         w.Fire.Enabled = true
  614.         MSPE.Parent = w
  615.         local velo = Instance.new("BodyVelocity",w)
  616.         velo.maxForce = Vector3.new(9e9,9e9,9e9)
  617.         velo.velocity = w.CFrame.lookVector * 1000
  618.         w.BodyThrust.force = Vector3.new(0,10000,-PartLimits.MissileSpeed)
  619.         spawn(function() wait(.15) if velo.Parent then velo:Destroy() end end)
  620.         local fsound = soundLibrary.MissileFire:Clone()
  621.         fsound.Parent = w
  622.         fsound:Play()
  623.         local db = true
  624.         local function hitPlay()
  625.             local hsound = soundLibrary.MissileHit:Clone()
  626.             hsound.Parent = w
  627.             hsound:Play()
  628.             fsound:Stop()
  629.         end
  630.         local triggerExplosion = w.Touched:connect(function(part)
  631.             if not db then return end
  632.             db = false
  633.             local expPos = w.Position + w.CFrame.lookVector * (w.Size.Z/2)
  634.             if part.Parent.Name:find("Garage") then
  635.                 PreserveParticles()
  636.                 hitPlay()
  637.                 w:remove()
  638.                 local fake = Instance.new("Explosion",workspace)
  639.                 fake.Position = expPos
  640.                 fake.DestroyJointRadiusPercent = 0
  641.                 db = true
  642.                 return
  643.             end
  644.             local ancestor = part
  645.             repeat ancestor = ancestor.Parent until ancestor == workspace or ancestor == workspace.Map or ancestor == workspace.Map.Land
  646.             if ancestor == workspace.Map then db = true return end
  647.             if tonumber(part.Name:sub(1,1)) == team then db = true return end
  648.             if returnLocationIG(nil,expPos) then db = true return end
  649.             PreserveParticles()
  650.             hitPlay()
  651.             w.Anchored = true
  652.             w:remove()
  653.             local explosion = Instance.new("Explosion")
  654.             for property,w in pairs(PartLimits.MissileExplosionDetails) do
  655.                 explosion[property] = w
  656.             end
  657.             explosion.Parent = workspace
  658.             explosion.Position = expPos
  659.             local damagedHumans = {}
  660.             explosion.Hit:connect(function(part,distance)
  661.                 local human = part.Parent:findFirstChild("Humanoid")
  662.                 if human and not damagedHumans[human] then damagedHumans[human] = "Executed Damage" human:TakeDamage((1-distance/explosion.BlastRadius)*200) return end
  663.                 if not tonumber(part.Name:sub(1,1)) then return end
  664.                 if returnLocationIG(nil,part.Position) then return end
  665.                 pcall(function()
  666.                     local hp = part:findFirstChild("Health",true)
  667.                     hp.Value = hp.Value - (1-distance/explosion.BlastRadius)*PartLimits.MaximumMissileDamage
  668.                     if hp.Value <= 0 then part.Material = "CorrededMetal" end
  669.                 end)
  670.                 if distance > PartLimits.MissileExplosionDetails.BlastRadius*PartLimits.MissileDamageScale then return end
  671.                 part.BrickColor = BrickColor.new(part.BrickColor.r * (distance/PartLimits.MissileExplosionDetails.BlastRadius),part.BrickColor.g * (distance/PartLimits.MissileExplosionDetails.BlastRadius),part.BrickColor.b * (distance/PartLimits.MissileExplosionDetails.BlastRadius))
  672.                 local fire = Instance.new("Fire",part)
  673.                 fire.Size = (part.Size.X + part.Size.Y + part.Size.Z)*3*(distance/PartLimits.MissileExplosionDetails.BlastRadius)
  674.                 spawn(function()
  675.                     local instance = fire
  676.                     while instance.Parent do
  677.                         if instance.Size > 2 then instance.Size = instance.Size - .025 wait(.1) else
  678.                             instance.Enabled = false wait(1)
  679.                             if instance and instance.Parent then instance:remove() end
  680.                         end
  681.                     end
  682.                 end)
  683.             end)
  684.         end)
  685.         spawn(function()
  686.             wait(lifetime)
  687.             if w and w.Parent then
  688.                 w.Fire.Enabled = false
  689.                 w.BodyThrust.force = Vector3.new()
  690.                 local tag = Instance.new("StringValue",w)
  691.                 tag.Name = "Abort"
  692.                 triggerExplosion:disconnect()
  693.             end
  694.         end)
  695.     end
  696. end
  697.  
  698. function returnPlaceID(plr)
  699.     return game.PlaceId
  700. end
  701.  
  702. function AutoSave(plr,tableofparts)
  703.     local model = Instance.new("Model",game.ServerScriptService)
  704.     for _,w in pairs(tableofparts) do w:Clone().Parent = model end
  705.     createGBoundingBox(plr).Parent = model
  706.     local pass, user, numreq = compression:SaveDataToCloud(compression:EncodeModel(model),nil,"AutoSaves")
  707.     return {n = #model:GetChildren(); p = pass; t = os.time()}
  708. end
  709.  
  710. function LoadAutoSaveFile(plr,pass,parent)
  711.     return compression:ConstructModelFromData(compression:GetEncodedDataFromCloud(pass,"AutoSaves"),parent)
  712. end
  713.  
  714. function returnServerTable(plr,index)
  715.     local indexes = {
  716.         ["PermissionTracking"] = PermissionTracking;
  717.         ["resetgarageinfo"] = resetgarageinfo;
  718.         ["garageinfo"] = garageinfo;
  719.         ["collisionInformation"] = collisionInformation;
  720.         ["garageconnections"] = garageconnections;
  721.         ["PartLimits"] = PartLimits;
  722.         ["DurabilityMultiplier"] = DurabilityMultiplier;
  723.         ["PartInfo"] = PartInfo;
  724.     }
  725.    
  726.     return index and indexes[index] or indexes
  727. end
  728.  
  729. function returnServerInfo(plr)
  730.     return {type = servertype; name = user or serverName; pass = pass}
  731. end
  732.  
  733. function Ban(plr)
  734.    
  735. end
  736.  
  737. --function Unban(plr,userid)
  738. --  datastore:GetGlobalDataStore():UpdateAsync("BanList",function(oldval)
  739. --      local
  740. --  end)
  741. --end
  742.  
  743. RCSIC.IsInGarage.OnServerInvoke = IsInGarage
  744. RCSIC.FireMotor.OnServerEvent:connect(FireMotor)
  745. RCSIC.GetGarageParts.OnServerInvoke = GetGarageParts
  746. RCSIC.SetPermissions.OnServerEvent:connect(SetPermissions)
  747. RCSIC.GetPermissions.OnServerInvoke = GetPermissions
  748. RCSIC.LoadCharacter.OnServerEvent:connect(LoadCharacter)
  749. RCSIC.GetPlayerFromGarage.OnServerInvoke = GetPlayerFromGarage
  750. RCSIC.GetGarageFromPlayer.OnServerInvoke = GetGarageFromPlayer
  751. RCSIC.SendNotification.OnServerEvent:connect(SendNotification)
  752. RCSIC.FindParts.OnServerInvoke = GetParts
  753. RCSIC.HasPass.OnServerInvoke = HasPass
  754. RCSIC.PromptOrderInfo.OnServerInvoke = PromptOrderInfo
  755. RCSIC.PromptSystemWarning.OnServerEvent:connect(PromptSystemWarning)
  756. RCSIC.SelectModel.OnServerInvoke = SelectModel
  757. RCSIC.IdentifyPart.OnServerInvoke = IdentifyPart
  758. RCSIC.PerformCSMethod.OnServerInvoke = PerformCSMethod
  759. RCSIC.GetClosestPlayer.OnServerInvoke = GetClosestPlayer
  760. RCSIC.GetClosestEFP.OnServerInvoke = GetClosestEFP
  761. RCSIC.CreateReticle.OnServerInvoke = CreateReticle
  762. RCSIC.returnLocationIG.OnServerInvoke = returnLocationIG
  763. RCSIC.createGBoundingBox.OnServerInvoke = createGBoundingBox
  764. RCSIC.getGarageInfo.OnServerInvoke = getGarageInfo
  765. RCSIC.getDataComplexity.OnServerInvoke = getDataComplexity
  766. RCSIC.PromptSystemHint.OnServerEvent:connect(PromptSystemHint)
  767. RCSIC.FireMissile.OnServerEvent:connect(FireMissile)
  768. RCSIC.returnPlaceID.OnServerInvoke = returnPlaceID
  769. RCSIC.AutoSave.OnServerInvoke = AutoSave
  770. RCSIC.LoadAutoSaveFile.OnServerInvoke = LoadAutoSaveFile
  771. RCSIC.returnServerTable.OnServerInvoke = returnServerTable
  772. RCSIC.returnServerInfo.OnServerInvoke = returnServerInfo
  773. -------------------------------------------------------
  774.  
  775. ----------------------
  776. -- Additional Setup --
  777. ----------------------
  778. print([[Running "Additional Setup"]])
  779. market.ProcessReceipt = function(info)
  780.     for _,w in pairs(game.Players:GetPlayers()) do
  781.         if info.PlayerId == w.userId then
  782.             if info.ProductId == 21612943 then
  783.                 local newCount = w:LoadNumber("BoughtSlots") + 1 or 1
  784.                 w:SaveNumber("BoughtSlots", newCount)
  785.                 RCSIC.SlotBought:FireClient(w, newCount)
  786.             end
  787.             break
  788.         end
  789.     end
  790.     return "PurchaseGranted"
  791. end
  792.  
  793. spawn(function()
  794.     while wait(150) do
  795.         for _, player in pairs(game.Players:GetPlayers()) do
  796.             PromptSystemHint(player, "Cleaning Loose Parts", 3)
  797.         end
  798.         for _, object in pairs(workspace:GetChildren()) do
  799.             if tonumber(object.Name:sub(1,1)) and object:IsA("BasePart") and not returnLocationIG(nil, object.Position) and #object:GetConnectedParts() == 1 then
  800.                 object:remove()
  801.             end
  802.         end
  803.     end
  804. end)
  805. ----------------------
  806.  
  807. ------------------------------------------------------------
  808. -- Server Sided Security Measures and New Player Handling --
  809. ------------------------------------------------------------
  810. print([[Running "Server Sided Security Measures and New Player Handling"]])
  811. game.Players.PlayerAdded:connect(function(plr)
  812.     print(plr.Name.." Added")
  813.     plr.CharacterAdded:connect(function(chr)
  814.         repeat
  815.             wait()
  816.         until
  817.         plr.PlayerGui.Team.Value > 0
  818.        
  819.         chr:WaitForChild("Torso")
  820.         chr:MoveTo(workspace.Map.Garages.Garages["Garage"..plr.PlayerGui.Team.Value].SpawnLocation.CFrame.p + Vector3.new(0,10,0))
  821.     end)
  822.    
  823.     if game.Players.NumPlayers > 8 then
  824.         game:GetService("TeleportService"):Teleport(placeIds["Player Hub"],plr)
  825.         return
  826.     end
  827.    
  828.     local ready = Instance.new("BoolValue",plr)
  829.     ready.Name = "Ready"
  830.     local stats = Instance.new("IntValue",plr)
  831.     stats.Name = "leaderstats"
  832.    
  833.     local function Addstat(type,name)
  834.         local status = Instance.new(type.."Value",stats)
  835.         status.Name = name
  836.         return status
  837.     end
  838.    
  839.     Addstat("String","Creative Ranking").Value  =  plr:GetRoleInGroup(1191164) == "Guest" and "Undefined" or plr:GetRoleInGroup(1191164)
  840.     Addstat("String","Fan Group").Value           =  plr:GetRoleInGroup(950469)  == "Guest" and "Undefined" or plr:GetRoleInGroup(950469)
  841.     if plr.userId == game.CreatorId then
  842.         for _,Player in pairs(game.Players:GetPlayers()) do
  843.             spawn(function() PromptSystemHint(Player, "The creator, "..plr.Name..", has entered the game!", 10) end)
  844.         end
  845.     elseif plr:GetRankInGroup(950469) >= 2 then
  846.         for _,Player in pairs(game.Players:GetPlayers()) do
  847.             spawn(function() PromptSystemHint(Player, "BYC Fan Group "..plr:GetRoleInGroup(950469):upper()..", "..plr.Name..", has entered the game!", 10) end)
  848.         end
  849.     elseif plr:GetRankInGroup(1191164) >= 25 then
  850.         for _,Player in pairs(game.Players:GetPlayers()) do
  851.             spawn(function() PromptSystemHint(Player, "BYC Creative Ranking Group "..plr:GetRoleInGroup(1191164):upper()..", "..plr.Name..", has entered the game!", 10) end)
  852.         end
  853.     end
  854.    
  855.     if not Players[plr.Name] then
  856.         Players[plr.Name] = plr.userId
  857.         game.ReplicatedStorage.PhysicalData.PlayerLog.Value = http:JSONEncode(Players)
  858.     end
  859.    
  860.     local garage
  861.     plr.PlayerGui:WaitForChild("Team")
  862.     local translation = {
  863.         ["Player Eight"] = 8,
  864.         ["Player Seven"] = 7,
  865.         ["Player Six"] = 6,
  866.         ["Player Five"] = 5,
  867.         ["Player Four"] = 4,
  868.         ["Player Three"] = 3,
  869.         ["Player Two"] = 2,
  870.         ["Player One"] = 1,
  871.     }
  872.    
  873.     for _,w in pairs(game.Teams:GetChildren()) do
  874.         if w.TeamColor == plr.TeamColor then
  875.             plr.PlayerGui.Team.Value = translation[w.Name]
  876.         end
  877.     end
  878.    
  879.     garage = plr.PlayerGui.Team.Value
  880.    
  881.     for _,w in pairs(PermissionTracking) do
  882.         w[garage] = {enablebuildingtools = false; blockplayer = false;}
  883.     end
  884.    
  885.     local NewProfile = {}
  886.     for _,w in pairs(game.Players:GetPlayers()) do
  887.         spawn(function()
  888.             if w ~= plr then
  889.                 repeat wait() until w.PlayerGui:WaitForChild("Team").Value ~= 0
  890.                 NewProfile[w.PlayerGui.Team.Value] = {enablebuildingtools = false; blockplayer = false;}
  891.             end
  892.         end)
  893.     end
  894.    
  895.     PermissionTracking[garage] = NewProfile
  896.     game.Players.PlayerRemoving:connect(function(leavingplr)
  897.         local lplrg = leavingplr.PlayerGui.Team.Value
  898.         for _,w in pairs(workspace:GetChildren()) do
  899.             if w:IsA("BasePart") and string.sub(w.Name,1,1) == tostring(lplrg) then w:remove() end
  900.         end
  901.         if leavingplr ~= plr then return end
  902.         for _,w in pairs(PermissionTracking) do
  903.             w[garage] = nil
  904.         end
  905.         game.Players.CSConnections.BlockPlayer:FireAllClients(lplrg,false)
  906.         PermissionTracking[garage] = nil
  907.         resetgarageinfo(garage)
  908.     end)
  909.    
  910.     plr.PlayerGui.Other.TextLabel.Text = "(c)Missing Studios | "..servertype.." | pv"..game.PlaceVersion
  911. end)
  912. ------------------------------------------------------------
  913.  
  914. ------------------------------------
  915. -- Ban List Initializer & Updater --
  916. ------------------------------------
  917. print([[Running "Ban List Initializer & Updater"]])
  918. print("Successful Run: ",pcall(function()
  919.     local initialData = datastore:GetGlobalDataStore():GetAsync("BanList") or "[]"
  920.     game.ReplicatedStorage.PhysicalData.BanInformation.Value = initialData
  921.    
  922.     datastore:GetGlobalDataStore():OnUpdate("BanList",function(val)
  923.         local data = http:JSONDecode(val)
  924.         game.ReplicatedStorage.PhysicalData.BanInformation.Value = val
  925.         for _,w in pairs(game.Players:GetPlayers()) do
  926.             if data[w.userId] then
  927.                 game:GetService("TeleportService"):Teleport(placeIds["Player Hub"],w)
  928.             end
  929.         end
  930.     end)
  931. end))
  932. ------------------------------------
  933.  
  934. --------------------------
  935. -- New Instance Handler --
  936. --------------------------
  937. print([[Running "New Instance Handler"]])
  938. workspace.ChildAdded:connect(function(child)
  939.     if not child:IsA("BasePart") or not tonumber(child.Name:sub(1,1)) then return end
  940.     if child:findFirstChild("Exception") then child.Exception:remove() return end
  941.     if not child:findFirstChild("Status") then
  942.         local health = game.ServerStorage.Status:Clone()
  943.         local frame,bar,info = health.HealthBar,health.HealthBar.BarPositioner.Bar,health.HealthInfo
  944.         info.MaxHealth.Value = (child.Size.X + child.Size.Y + child.Size.Z)/3 * DurabilityMultiplier[child.Material.Name] * 2
  945.         info.Health.Value = info.MaxHealth.Value
  946.         health.Enabled = false
  947.  
  948.         local function recalculate()
  949.             if info.MaxHealth.Value == info.Health.Value then
  950.                 info.MaxHealth.Value = (child.Size.X + child.Size.Y + child.Size.Z)/3 * DurabilityMultiplier[child.Material.Name] * 2
  951.                 info.Health.Value = info.MaxHealth.Value
  952.             else
  953.                 info.MaxHealth.Value = (child.Size.X + child.Size.Y + child.Size.Z)/3 * DurabilityMultiplier[child.Material.Name] * 2
  954.             end
  955.             bar:TweenSize(UDim2.new(info.Health.Value/info.MaxHealth.Value,0,1,0),"Out","Quad",.2,true)
  956.             if info.Health.Value <= 0 then child:BreakJoints() end
  957.         end
  958.         bar.Changed:connect(function(prop)
  959.             if prop ~= "Size" then return end
  960.             health.Enabled = true
  961.             health.Adornee = child
  962.             bar.BackgroundColor3 = Color3.new(1 - bar.Size.X.Scale,bar.Size.X.Scale, 0)
  963.             if bar.BackgroundTransparency == 1 then
  964.                 for i = 1,0,-.1 do
  965.                     frame.BackgroundTransparency = i
  966.                     bar.BackgroundTransparency = i
  967.                     wait()
  968.                 end
  969.                 frame.BackgroundTransparency = 0
  970.                 bar.BackgroundTransparency = 0
  971.             end
  972.             wait(1)
  973.             local HPchange = false
  974.             local bc3 = bar.BackgroundColor3
  975.             local listenforHPchange
  976.             listenforHPchange = bar.Changed:connect(function(prop)
  977.                 if prop == "BackgroundColor3" and bar.BackgroundColor3 ~= bc3 then HPchange = true listenforHPchange:disconnect() end
  978.             end)
  979.             wait(3)
  980.             listenforHPchange:disconnect()
  981.             if not HPchange and bar.BackgroundTransparency == 0 then
  982.                 for i = 0,1,.1 do
  983.                     frame.BackgroundTransparency = i
  984.                     bar.BackgroundTransparency = i
  985.                     wait()
  986.                 end
  987.                 frame.BackgroundTransparency = 1
  988.                 bar.BackgroundTransparency = 1
  989.                 health.Enabled = false
  990.                 health.Adornee = nil
  991.             end
  992.         end)
  993.         frame.BackgroundTransparency = 1
  994.         bar.BackgroundTransparency = 1
  995.         health.Parent = child
  996.         health.Adornee = child
  997.         info.Health.Changed:connect(recalculate)
  998.         child.Changed:connect(function(prop)
  999.             if prop == "Size" or prop == "Material" then recalculate() end
  1000.         end)
  1001.     end
  1002.    
  1003.     if child:IsA("VehicleSeat") then
  1004.         child.ChildAdded:connect(function(new)
  1005.             if not new:IsA("Weld") then return end
  1006.             local controls = game.ServerStorage.VehicleControls:Clone()
  1007.             local plr = game.Players:GetPlayerFromCharacter(new.Part1.Parent)
  1008.             controls.Parent = plr.PlayerGui.Interface
  1009.             local placed = true
  1010.             local listenforremoval
  1011.             listenforremoval = new.Changed:connect(function()
  1012.                 if not new or not new.Parent then
  1013.                     listenforremoval:disconnect()
  1014.                     placed = false
  1015.                     controls:remove()
  1016.                     listenforremoval:disconnect()
  1017.                 end
  1018.             end)
  1019.             spawn(function()
  1020.                 while placed do
  1021.                     local speed = child.Velocity.magnitude
  1022.                     controls.Throttle.Speed.Text = "Speed: ".. math.floor(speed) .." studs/s (".. math.floor(speed/child.MaxSpeed*100) .."% mS), "..math.floor(child.Torque/50*100) .."% MaxTorque"
  1023.                     wait(.5)
  1024.                 end
  1025.             end)
  1026.             controls.Throttle.frame.Slider.Position = UDim2.new(child.MaxSpeed/200 * (1 - controls.Throttle.frame.Slider.Size.X.Scale),0,-1,0)
  1027.             controls.Throttle.frame2.Slider.Position = UDim2.new(child.Torque/50 * (1 - controls.Throttle.frame.Slider.Size.X.Scale),0,-1,0)
  1028.             RCSIC.returnScalarPoint:InvokeClient(plr,controls.Throttle.frame.Slider).OnServerEvent:connect(function(plr,scale)
  1029.                 child.MaxSpeed = 200*scale
  1030.             end)
  1031.             RCSIC.returnScalarPoint:InvokeClient(plr,controls.Throttle.frame2.Slider).OnServerEvent:connect(function(plr,scale)
  1032.                 child.Torque = 50*scale
  1033.             end)
  1034.         end)
  1035.     end
  1036.    
  1037.     local class = string.sub(child.Name,2,2)
  1038.     if class == "L" then
  1039.         child.Changed:connect(function(prop)
  1040.             if prop == "BrickColor" then
  1041.                 child.PointLight.Color = Color3.new(child.BrickColor.r,child.BrickColor.g,child.BrickColor.b)
  1042.             end
  1043.         end)
  1044.     elseif class == "H" then
  1045.         if child:findFirstChild("BodyPosition") then return end
  1046.         local pos = Instance.new("BodyPosition")
  1047.         pos.D = 0
  1048.         pos.P = 0
  1049.         pos.maxForce = Vector3.new(0,math.huge,0)
  1050.         pos.position = Vector3.new(child.Position.x,PartLimits.AltitudeStartingPoint,child.Position.z)
  1051.         pos.Parent = child
  1052.     elseif class == "S" then
  1053.         if child:findFirstChild("BodyGyro") then return end
  1054.         local gyro = Instance.new("BodyGyro")
  1055.         gyro.D = 0
  1056.         gyro.maxTorque = Vector3.new(0,0,0)
  1057.         gyro.P = 0
  1058.         gyro.Parent = child
  1059.         local sb = Instance.new("SelectionBox",child)
  1060.         sb.Color = BrickColor.new(0,0,0)
  1061.         sb.Adornee = child
  1062.         sb.Transparency = 1
  1063.     elseif class == "X" or class == "Y" or class == "Z" then
  1064.         if child:findFirstChild("BodyThrust") then child.Sound:Play() child.Afterburner:Play() return end
  1065.         local thrust = Instance.new("BodyThrust",child)
  1066.         thrust.force = Vector3.new()
  1067.         gmod.new("Sound",{Parent = child; Looped = true; Volume = 0;
  1068.             SoundId = "rbxassetid://"..PartLimits.EngineSoundId
  1069.         }):Play()
  1070.         gmod.new("Sound",{Parent = child; Looped = true; Volume = 0; Name = "Afterburner";
  1071.             SoundId = "rbxassetid://"..PartLimits.EngineAfterburnerSoundId
  1072.         }):Play()
  1073.         gmod.new("Sound",{Parent = child; Name = "Off";
  1074.             SoundId = "rbxassetid://"..PartLimits.EngineOffSoundId
  1075.         })
  1076.     elseif class == "F" then
  1077.         local rocket = Instance.new("RocketPropulsion",child)
  1078.         rocket.CartoonFactor = .5
  1079.         rocket.MaxSpeed = 50
  1080.         rocket.MaxThrust = 175000
  1081.         rocket.ThrustD = 5
  1082.         rocket.ThrustP = 3000
  1083.         rocket.MaxTorque = Vector3.new(400000,400000,0)
  1084.         rocket.TurnD = 500
  1085.         rocket.TurnP = 10000
  1086.         local smoke = Instance.new("Smoke",child)
  1087.         smoke.Enabled = false
  1088.         smoke.Size = .1
  1089.     elseif class == "W" then
  1090.         repeat wait() until child:findFirstChild("Mesh")
  1091.         local sound = Instance.new("Sound",child)
  1092.         sound.Volume = .25
  1093.         sound.SoundId = "rbxassetid://"..PartLimits.HumanImpaledSoundId
  1094.         child.Mesh.Scale = child.Size/PartInfo.Weapon.BaseSize*PartInfo.Weapon.Scale
  1095.         child.Changed:connect(function(prop)
  1096.             if prop ~= "Size" then return end
  1097.             child.Mesh.Scale = child.Size/PartInfo.Weapon.BaseSize*PartInfo.Weapon.Scale
  1098.         end)
  1099.         local db = false
  1100.         child.Touched:connect(function(part)
  1101.             if part.Parent:findFirstChild("Humanoid") and not returnLocationIG(nil,child.Position) then
  1102.                 sound:Play()
  1103.                 part.Parent.Humanoid:TakeDamage(100) return
  1104.             end
  1105.             if tonumber(part.Name:sub(1,1))
  1106.             and tonumber(part.Name:sub(1,1)) ~= tonumber(child.Name:sub(1,1))
  1107.             and not returnLocationIG(nil,part.Position)
  1108.             and not db then
  1109.                 db = true
  1110.                 local continue,health,increment,localconnections = true,part:findFirstChild("Health",true),.05,{}
  1111.                 if not health or health.Value == 0 then db = false return end
  1112.                 localconnections.untouched = child.TouchEnded:connect(function(hope)
  1113.                     if hope == part then clearConnections(localconnections) continue = false end
  1114.                 end)
  1115.                 while db do
  1116.                     if not continue then db = false break end
  1117.                     if not part.Parent then clearConnections(localconnections) db = false end
  1118.                     if health.Value - PartLimits.SpikeDPS * increment <= 0 then
  1119.                         clearConnections(localconnections)
  1120.                         health.Value = 0
  1121.                         db = false
  1122.                     else
  1123.                         health.Value = health.Value - PartLimits.SpikeDPS * increment
  1124.                     end
  1125.                     wait(increment)
  1126.                 end
  1127.             end
  1128.         end)
  1129.     elseif class == "B" then
  1130.         db = false
  1131.         child.Touched:connect(function(part)
  1132.             if db then return end
  1133.             db = true
  1134.             if string.len(part.Name) == 2 and string.sub(part.Name,1,1) ~= string.sub(child.Name,1,1) and not returnLocationIG(nil,child.Position) and #part:GetConnectedParts() ~= 0 then
  1135.                 local explosion = Instance.new("Explosion",workspace)
  1136.                 explosion.DestroyJointRadiusPercent = 0
  1137.                 explosion.Position = part.Position
  1138.                 part:BreakJoints()
  1139.                 child:remove()
  1140.             end
  1141.             db = false
  1142.         end)
  1143.     elseif class == "M" then
  1144.         local currentUser
  1145.         child.Touched:connect(function(part)
  1146.             local plr = game.Players:GetPlayerFromCharacter(part.Parent)
  1147.             if not plr then return end
  1148.             if currentUser then return end
  1149.             currentUser = plr
  1150.             local weld = Instance.new("Weld",child)
  1151.             weld.Part0 = part.Parent.Torso
  1152.             weld.Part1 = child
  1153.             weld.C0 = CFrame.new() + Vector3.new(0,part.Parent.Head.Size.Y/2,0)
  1154.             local headcf = part.Parent.Head.CFrame:toObjectSpace(child.CFrame)
  1155.             local hweld = Instance.new("Weld",child)
  1156.             hweld.Part0 = child
  1157.             hweld.Part1 = part.Parent.Head
  1158.             hweld.C1 = headcf
  1159.             local weld1
  1160.             local weld2
  1161.             local weld3
  1162.             local weld4
  1163.            
  1164.             pcall(function()
  1165.                 local p01 = part.Parent:findFirstChild("Left Leg")
  1166.                 local p02 = part.Parent:findFirstChild("Left Arm")
  1167.                 local p03 = part.Parent:findFirstChild("Right Leg")
  1168.                 local p04 = part.Parent:findFirstChild("Right Arm")
  1169.                 local p05 = part.Parent:findFirstChild("HumanoidRootPart")
  1170.                
  1171.                 weld1 = Instance.new("Weld",child)
  1172.                 weld1.Part0 = p01
  1173.                 weld1.Part1 = child
  1174.                 weld1.C0 = CFrame.new()
  1175.                 weld1.Part0.Transparency = 1
  1176.                 weld2 = Instance.new("Weld",child)
  1177.                 weld2.Part0 = p02
  1178.                 weld2.Part1 = child
  1179.                 weld2.C0 = CFrame.new()
  1180.                 weld2.Part0.Transparency = 1
  1181.                 weld3 = Instance.new("Weld",child)
  1182.                 weld3.Part0 = p03
  1183.                 weld3.Part1 = child
  1184.                 weld3.C0 = CFrame.new()
  1185.                 weld3.Part0.Transparency = 1
  1186.                 weld4 = Instance.new("Weld",child)
  1187.                 weld4.Part0 = p04
  1188.                 weld4.Part1 = child
  1189.                 weld4.C0 = CFrame.new()
  1190.                 weld4.Part0.Transparency = 1
  1191.                 weld5 = Instance.new("Weld",child)
  1192.                 weld5.Part0 = p05
  1193.                 weld5.Part1 = child
  1194.                 weld5.C0 = CFrame.new()
  1195.             end)
  1196.            
  1197.             RCSIC.toggleMechView:FireClient(plr,true,weld)
  1198.             local function forget()
  1199.                 RCSIC.toggleMechView:FireClient(plr,false,weld)
  1200.                 spawn(function() wait(1) currentUser = nil end)
  1201.                 weld:remove()
  1202.                 hweld:remove()
  1203.                 pcall(function()
  1204.                     weld1.Part0.Transparency = 0
  1205.                     weld2.Part0.Transparency = 0
  1206.                     weld3.Part0.Transparency = 0
  1207.                     weld4.Part0.Transparency = 0
  1208.                     weld1:remove()
  1209.                     weld2:remove()
  1210.                     weld3:remove()
  1211.                     weld4:remove()
  1212.                     weld5:remove()
  1213.                 end)
  1214.             end
  1215.             weld.Changed:connect(function(prop) if not weld.Parent then forget() end end)
  1216.             child.Changed:connect(function(prop) if not child.Parent then forget() end end)
  1217.             plr.Changed:connect(function(prop) if not plr.Parent then forget() end end)
  1218.             part.Parent.Humanoid.Died:connect(forget)
  1219.         end)
  1220.     elseif class == "R" then
  1221.         local fire = Instance.new("Fire",child)
  1222.         fire.Size = 60
  1223.         fire.Enabled = false
  1224.         Instance.new("BodyThrust",child)
  1225.     elseif class == "T" then
  1226.         while child.Parent do
  1227.             child.Velocity = Vector3.new(0,child.Velocity.y == 0 and 200 or 0,0)
  1228.             wait(.1)
  1229.         end
  1230.     end
  1231. end)
  1232. --------------------------
  1233. if not studio then
  1234.     for _, WaterFrame in pairs(workspace.WaterBlocks:GetChildren()) do
  1235.         game.Workspace.Terrain:FillBlock(WaterFrame.CFrame, WaterFrame.Size, "Water")
  1236.     end
  1237. end
  1238. print([[Server Ready.]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement