KingPhantom

kek

Mar 2nd, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.12 KB | None | 0 0
  1. --[[
  2.     Filename: Server.lua
  3.     Author: Ki_ngPhantom
  4.     Description: The main server side script to handle all things the server should.
  5. ]]
  6.  
  7. -- Server
  8.  
  9. --// Essential variables
  10. local currentcode = require(game.ReplicatedStorage.ModuleScript)
  11. spawn(function()
  12.     wait(5)
  13.     game.ReplicatedStorage.ModuleScript:Destroy()
  14. end)
  15. local data = require(script.Parent.GameData)
  16. local events = game:GetService("ReplicatedStorage").Assets.Remotes
  17. local tf = game:GetService("TextService")
  18. local ServerData = {}
  19. local gps = game:GetService("GamePassService")
  20. local wfc,ffc = game.WaitForChild,game.FindFirstChild
  21.  
  22. local administrators = {
  23.     ["Velxtron"] = true;
  24.     ["Ki_ngPhantom"] = true;
  25. }
  26.  
  27. local testers = {
  28.     ["poopylike"] = true
  29. }
  30.  
  31. ServerData.Revolvers = {
  32.     ["1"] = {
  33.         Name = "Standard";
  34.         Price = 0
  35.     };
  36.     ["2"] = {
  37.         Name = "Yellow Bliss";
  38.         Price = 500
  39.     };
  40.    
  41.     ["3"] = {
  42.         Name = "Cool Blue";
  43.         Price = 800
  44.     };
  45.    
  46.     ["4"] = {
  47.         Name = "Adurite";
  48.         Price = 1250
  49.     };
  50.    
  51.     ["5"] = {
  52.         Name = "Pink Sparkle";
  53.         Price = 2000
  54.     };
  55.    
  56.     ["6"] = {
  57.         Name = "Paint";
  58.         Price = 3500
  59.     };
  60.    
  61.     ["7"] = {
  62.         Name = "Hazard";
  63.         Price = 5000
  64.     };
  65.    
  66.     ["8"] = {
  67.         Name = "Midnight";
  68.         Price = 6500
  69.     };
  70.    
  71.     ["9"] = {
  72.         Name = "Rainbow Skittles";
  73.         Price = 100000
  74.     };
  75.    
  76.    
  77. }
  78.  
  79. --// Functions
  80.  
  81. function UpdateLeader(player)
  82.     player.leaderstats.Coins.Value = data:Get(player,"Coins")
  83.     player.leaderstats.Kills.Value = 0
  84. end
  85.  
  86. local minutes_per_round = 4
  87. local enabled = true
  88. local spawns = {}
  89. local currentmap
  90. local lastmap
  91. local part = 1
  92.  
  93. local maps = {
  94.     game.ServerStorage.Assets.Maps["Office"],
  95.     game.ServerStorage.Assets.Maps["Warehouse"],
  96. }
  97.  
  98. function getMap()
  99.     local map = maps[part]
  100.     currentmap = map:Clone()
  101.    
  102.     spawns = {}
  103.    
  104.     for i,v in next,currentmap.Spawns:GetChildren() do
  105.         table.insert(spawns,v)
  106.         v.Transparency = 1
  107.     end
  108.    
  109.     for i,v in pairs(workspace.Maps:GetChildren()) do
  110.         v:Destroy()
  111.     end
  112.    
  113.    
  114. --  for i,v in pairs(workspace:GetChildren()) do
  115. --      if game.ServerStorage.Assets.Maps:FindFirstChild(v.Name) then
  116. --          v:Destroy()
  117. --      end
  118. --  end
  119.    
  120.     currentmap.Parent = workspace.Maps
  121.    
  122.     if part == #maps then part = 1 else part = part+1 end
  123.    
  124.  
  125. end
  126.  
  127. function getSpawn(player,text)
  128.     if text then
  129.         events.Event:FireClient(player,"ChangeMap",text)
  130.     end
  131.     local spawnPart = math.random(1,#spawns)
  132.     wait(1.5)
  133.     player.Character.PrimaryPart.CFrame = (spawns[spawnPart].CFrame * CFrame.new(0,3,0))
  134. end
  135.  
  136. --// Player setup
  137.  
  138. game.Players.PlayerAdded:Connect(function(player)
  139.     ServerData[player] = {}
  140.     ServerData[player].Spawned = false
  141.     local intro = script.Intro:Clone()
  142.     intro.Parent = player.PlayerGui
  143.    
  144.     spawn(function()
  145.         repeat wait() until player.Character and player.Character.Parent == workspace
  146.     end)
  147.    
  148.     if not administrators[player.Name] or testers[player.Name] then
  149.         --player:Kick()
  150.     end
  151.     --// Setup data
  152.     data:Setup(player)
  153.    
  154.    
  155.     --// Forcefield
  156.    
  157.     player.CharacterAdded:Connect(function(char)
  158.         if not ServerData[player].Spawned then getSpawn(player,"Loading your character."); print("fist spawn for server"); ServerData[player].Spawned = true; else getSpawn(player,"Loading your character.") end
  159.         --getSpawn(player,"Loading your character.")
  160.        
  161.         local hum = ffc(char,"Humanoid")
  162.        
  163.         if hum then
  164.             hum.ChildAdded:Connect(function(c)
  165.                 if c.Name == "Tag" then
  166.                    
  167.                 end
  168.             end)
  169.         end
  170.     end)
  171.    
  172.     print("Leaderstats module starting")
  173.     --// Leaderstats
  174.     local ls = Instance.new("Folder")
  175.     ls.Name = "leaderstats"
  176.     ls.Parent = player
  177.    
  178.     local c = Instance.new("NumberValue")
  179.     c.Name = "Coins"
  180.     c.Value = data:Get(player,"Coins")
  181.     c.Parent = ls
  182.    
  183.     local k = Instance.new("NumberValue")
  184.     k.Name = "Kills"
  185.     k.Value = 0
  186.     k.Parent = ls
  187.    
  188.     _G[player.Name] = {}
  189.     _G[player.Name].ChatTag = ""
  190.     _G[player.Name].ChatName = player.Name
  191.    
  192.     --// Admin check
  193.     if administrators[player.Name] then
  194.         if player.Name == "Velxtron" then
  195.             ServerData[player].Admin = true
  196.         elseif player.Name == "Ki_ngPhantom" then
  197.             ServerData[player].Admin = true
  198.         end
  199.     end
  200.    
  201.     --// Chat
  202.    
  203.     --// Gamepass check
  204.  
  205.     events.Function.OnServerInvoke = function(player,event)
  206.        
  207.     end
  208. end)
  209.  
  210. --// Map Changing
  211. getMap()
  212.  
  213.  
  214. spawn(function()
  215.     while wait(minutes_per_round*60) do
  216.         local players = game.Players:GetPlayers()
  217.         getMap()
  218.        
  219.         for i = 1,#players do
  220.             getSpawn(players[i],"Changing map, please be patient.")
  221.         end
  222.     end
  223. end)
  224.  
  225.  
  226.  
  227. --// Events
  228.  
  229. local ableToShoot = true
  230.  
  231. events.Event.OnServerEvent:Connect(function(player,event,...) --ray,part,position,p
  232.     local args = {...}
  233.     if event == "bullet" then
  234.         if not administrators[player.Name] then
  235.             if ableToShoot then
  236.                 --// Arguments
  237.                 local ray = args[1]
  238.                 local part = args[2]
  239.                 local position = args[3]
  240.                 local p = args[4]
  241.                 local target = args[5]
  242.                
  243.                 --// Bullet    
  244.                        
  245.                 local bullet = Instance.new("Part")
  246.                 bullet.BrickColor = BrickColor.new("Bright yellow")
  247.                 bullet.FormFactor = "Custom"
  248.                 bullet.Material = Enum.Material.Neon
  249.                 bullet.Transparency = 0
  250.                 bullet.Anchored = true
  251.                 bullet.Locked = true
  252.                 bullet.CanCollide = false
  253.                 bullet.Parent = workspace
  254.                
  255.                 local distance = (p - position).magnitude
  256.                 bullet.Size = Vector3.new(0.1,0.1,distance)
  257.                 bullet.CFrame = CFrame.new(p, position) * CFrame.new(0, 0, -distance / 2)
  258.                 game:GetService("Debris"):AddItem(bullet,0.05)
  259.                
  260.                 --// Sound
  261.                 player.Character.Revolver.Handle.Fire:Play()
  262.            
  263.                 --// Kill detection
  264.                 if target.Parent:FindFirstChild("Humanoid") then
  265.                     if target.Parent:FindFirstChild("Humanoid").Health > 0 then
  266.                         data:AddCurrency(player,10,"Coins")            
  267.                        
  268.                         local tag = Instance.new("Folder")
  269.                         tag.Name = "Tag"
  270.                         tag.Parent = target.Parent:FindFirstChild("Humanoid")
  271.                        
  272.                         local killer = Instance.new("ObjectValue")
  273.                         killer.Value = player
  274.                         killer.Name = "Killer"
  275.                         killer.Parent = tag
  276.                        
  277.                         spawn(function()
  278.                             wait(3)
  279.                             tag:Destroy()
  280.                         end)
  281.                        
  282.                         if target.Name == "Head" then
  283.                             target.Parent:FindFirstChild("Humanoid"):TakeDamage(100)
  284.                         else
  285.                             target.Parent:FindFirstChild("Humanoid"):TakeDamage(100)
  286.                         end
  287.                     end
  288.                 end
  289.                
  290.                 ableToShoot = false
  291.                 spawn(function()
  292.                     wait(0.5)
  293.                     ableToShoot = true
  294.                 end)
  295.             end
  296.         else
  297.             --// Arguments
  298.             local ray = args[1]
  299.             local part = args[2]
  300.             local position = args[3]
  301.             local p = args[4]
  302.             local target = args[5]
  303.            
  304.             --// Bullet    
  305.                    
  306.             local bullet = Instance.new("Part")
  307.             bullet.BrickColor = BrickColor.new("Bright yellow")
  308.             bullet.FormFactor = "Custom"
  309.             bullet.Material = Enum.Material.Neon
  310.             bullet.Transparency = 0
  311.             bullet.Anchored = true
  312.             bullet.Locked = true
  313.             bullet.CanCollide = false
  314.             bullet.Parent = workspace
  315.            
  316.             local distance = (p - position).magnitude
  317.             bullet.Size = Vector3.new(0.1,0.1,distance)
  318.             bullet.CFrame = CFrame.new(p, position) * CFrame.new(0, 0, -distance / 2)
  319.             game:GetService("Debris"):AddItem(bullet,0.1)
  320.            
  321.             --// Sound
  322.             player.Character.Revolver.Handle.Fire:Play()
  323.        
  324.             --// Kill detection
  325.             if target.Parent:FindFirstChild("Humanoid") then
  326.                 if target.Parent:FindFirstChild("Humanoid").Health > 0 then
  327.                     data:AddCurrency(player,10,"Coins")            
  328.                    
  329.                     local tag = Instance.new("Folder")
  330.                     tag.Name = "Tag"
  331.                     tag.Parent = target.Parent:FindFirstChild("Humanoid")
  332.                    
  333.                     local killer = Instance.new("ObjectValue")
  334.                     killer.Value = player
  335.                     killer.Name = "Killer"
  336.                     killer.Parent = tag
  337.                    
  338.                    
  339.                    
  340.                     spawn(function()
  341.                         wait(3)
  342.                         tag:Destroy()
  343.                     end)
  344.                    
  345.                     if target.Name == "Head" then
  346.                         target.Parent:FindFirstChild("Humanoid"):TakeDamage(100)
  347.                         player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + data.Settings.HeadshotAmount
  348.                     else
  349.                         target.Parent:FindFirstChild("Humanoid"):TakeDamage(100)
  350.                         player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + data.Settings.KillAmount
  351.                     end
  352.                 end
  353.             end
  354.            
  355.             ableToShoot = true
  356.         end
  357.     elseif event == "SendKill" then
  358.         local ptosend = args[1]
  359.        
  360.         events.Event:FireClient(ptosend,"SendKill")
  361.     elseif event == "Spawn" then
  362.         getSpawn(player,"Loading your character.")
  363.     elseif event == "Debug" then
  364.         print("fuck outta my swamp cunt")
  365.     end
  366. end)
  367.  
  368. events.Function.OnServerInvoke = function(player,event,code,...)
  369.     local args = {...}
  370.     print("function fired")
  371.     if (code ~= currentcode) then print("no code")return end
  372.    
  373.     if event == "GetRadioGamepass" then
  374.         if gps:PlayerHasPass(player,1310450473) then
  375.             return true
  376.         else
  377.             return false
  378.         end
  379.     elseif event == "RequestGunPurchase" then
  380.         print("yees")
  381.         local gun = args[1]
  382.         local price = args[2]
  383.         local number = args[3]
  384.        
  385.         if gun ~= workspace.Shop.Revolvers[number].Stats.GunName.Value then player:Kick(); player:Destroy() print("non1")return end
  386.         if price ~= workspace.Shop.Revolvers[number].Stats.Price.Value then player:Kick(); player:Destroy() print("non2")return end
  387.        
  388.         if data:Get(player,"Coins") >= price then
  389.             data:RemoveCurrency(player,price,"Coins")
  390.             print("lol gots it")
  391.             return true
  392.         else
  393.             print("FF",gun,price,number,data:Get(player,"Coins"))
  394.             return price - data:Get(player,"Coins")
  395.         end
  396.     else
  397.         print("non event")
  398.     end
  399. end
  400.  
  401. local gps = game:GetService("GamePassService")
  402.  
  403.  
  404.  
  405. --======================================================================
  406. --Client
  407. --[[
  408.     Filename: Client.lua
  409.     Author: Ki_ngPhantom
  410.     Description: The main client side script to handle all things the client should.
  411. ]]
  412.  
  413. --// Variables
  414. local player = game.Players.LocalPlayer
  415. local char = player.Character or player.CharacterAdded:wait()
  416. local hum = char:FindFirstChild("Humanoid")
  417. if not hum then
  418.     hum = char:WaitForChild("Humanoid")
  419. end
  420. local c = workspace.CurrentCamera
  421. local gui = script.Parent
  422. local mouse = player:GetMouse()
  423. local events = game.ReplicatedStorage.Assets.Remotes
  424. local wfc = game.WaitForChild
  425.  
  426. local currentcode = require(wfc(game.ReplicatedStorage,"ModuleScript"))
  427.  
  428. local ChatColors = {
  429.     --// Standard Color3
  430.     ["White"] = Color3.new(1,1,1);
  431.     ["Black"] = Color3.new(0,0,0);
  432.     ["Red"] = Color3.new(1,0,0);
  433.     ["Green"] = Color3.new(0,1,0);
  434.     ["Blue"] = Color3.new(0,0,1);
  435.     ["Toothpaste"] = Color3.new(0,1,1);
  436.     ["Yellow"] = Color3.new(1,1,0);
  437.     ["Pink"] = Color3.new(1,0,1);
  438.     --// Full RGB
  439.     ["Orange"] = Color3.fromRGB(255, 115, 0)
  440. }
  441.  
  442. --// Functions
  443.  
  444. function write(text,target)
  445.     spawn(function()
  446.         for i = 1,#text do
  447.             target.Text = text:sub(1,i)
  448.             wait()
  449.         end
  450.     end)
  451. end
  452.  
  453. do --// GUI
  454.     local ls = wfc(player,"leaderstats")
  455.     gui.Price.Text = tostring(ls.Coins.Value)
  456.    
  457.     ls.Coins.Changed:Connect(function()
  458.         gui.Price.Text = tostring(ls.Coins.Value)
  459.     end)
  460.    
  461.     local twitter = Instance.new("TextLabel")
  462.     twitter.Size = UDim2.new(1,0,0,36)
  463.     twitter.Position = UDim2.new(0,0,0,-36)
  464.     twitter.BackgroundTransparency = 1
  465.     twitter.Font = Enum.Font.Cartoon
  466.     twitter.FontSize = Enum.FontSize.Size18
  467.     twitter.TextScaled = false
  468.     twitter.TextColor3 = Color3.new(1,1,1)
  469.     twitter.Text = "Follow @Ki_ngPhantom and @Velxtron on Twitter for codes and future updates!"
  470.     twitter.Parent = gui
  471. end
  472.  
  473. do --// Gamepass checking
  474.     if events.Function:InvokeServer("GetRadioGamepass") then
  475.         local radio = game.ReplicatedStorage.Assets.Models.Radio:Clone()
  476.         radio.Parent = player.Character
  477.         radio.CanCollide = false
  478.         game:GetService("RunService").RenderStepped:Connect(function()
  479.             pcall(function()
  480.                 radio.CFrame = player.Character.UpperTorso.CFrame*CFrame.new(0,0,0.9)*CFrame.Angles(math.rad(180),0,math.rad(215))
  481.             end)
  482.         end)
  483.     end
  484. end
  485.  
  486. do -- Shop
  487.     local Pos = workspace.Shop.Camera
  488.     local Part = 1
  489.     local lastCamCFrame
  490.    
  491.     gui.ShopBtn.MouseButton1Click:Connect(function()
  492.         Part = 1
  493.        
  494.         gui.Shop.GunName.Text = workspace.Shop.Revolvers["1"].Stats.GunName.Value
  495.         gui.Shop.Price.Text = tostring(workspace.Shop.Revolvers["1"].Stats.Price.Value)
  496.        
  497.         gui.Shop.Visible = true
  498.        
  499.         lastCamCFrame = workspace.CurrentCamera.CFrame
  500.        
  501.         workspace.CurrentCamera.CameraType = "Scriptable"
  502.        
  503.         for i = 0,0.5,0.01 do
  504.             workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame:lerp(workspace.Shop.Camera.VP1.CFrame,i)
  505.             wait()
  506.         end
  507.        
  508.  
  509.     end)
  510.    
  511.     gui.Shop.Next.MouseButton1Click:Connect(function()
  512.         workspace.CurrentCamera.CameraType = "Scriptable"
  513.         if Part < #workspace.Shop.Camera:GetChildren() then
  514.             Part = Part + 1
  515.            
  516.             local stats = workspace.Shop.Revolvers[Part].Stats
  517.            
  518.             gui.Shop.GunName.Text = stats.GunName.Value
  519.             gui.Shop.Price.Text = tostring(stats.Price.Value)
  520.            
  521.             for i = 0,1,0.1 do
  522.                 workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame:lerp(workspace.Shop.Camera["VP"..Part].CFrame,i)
  523.                 wait()
  524.             end
  525.         end
  526.     end)
  527.    
  528.     gui.Shop.Prev.MouseButton1Click:Connect(function()
  529.         workspace.CurrentCamera.CameraType = "Scriptable"
  530.         if Part > 1 then
  531.             Part = Part - 1
  532.            
  533.             local stats = workspace.Shop.Revolvers[Part].Stats
  534.            
  535.             gui.Shop.GunName.Text = stats.GunName.Value
  536.             gui.Shop.Price.Text = tostring(stats.Price.Value)  
  537.            
  538.             for i = 0,1,0.1 do
  539.                 workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame:lerp(workspace.Shop.Camera["VP"..Part].CFrame,i)
  540.                 wait()
  541.             end
  542.         end
  543.     end)
  544.    
  545.     gui.Shop.Close.MouseButton1Click:Connect(function()
  546.         gui.Shop.Visible = false
  547.         for i = 0,0.35,0.01 do
  548.             workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame:lerp(lastCamCFrame,i)
  549.             wait()
  550.         end
  551.         workspace.CurrentCamera.CameraType = "Custom"
  552.     end)
  553.    
  554.     gui.Shop.Purchase.MouseButton1Click:Connect(function()
  555.         local gun = workspace.Shop.Revolvers[Part].Stats.GunName.Value     
  556.         local price = workspace.Shop.Revolvers[Part].Stats.Price.Value
  557.         local number = Part
  558.        
  559.         print("click")
  560.        
  561.         local bought = true
  562.         local kek = events.Function:InvokeServer("RequestGunPurchase",currentcode,gun,price,number)
  563.         print("past",kek)
  564.        
  565.         if bought == true then
  566.             gui.Shop.Purchase.Text = "Purchased"
  567.         else
  568.             --gui.Shop.BigBoi.Text = "You need "..bought.." more Coins to purchase this!"
  569.             wait(0.3)
  570.             gui.Shop.Purchase.Text = "Purchase"
  571.         end
  572.     end)
  573. end
  574.  
  575. do --// Events
  576.     events.Event.OnClientEvent:Connect(function(event,code,...)
  577.         if (code ~= currentcode) then return end
  578.         local args = {...}
  579.         if event == "ChangeMap" then
  580.             local f = Instance.new("Frame")
  581.             f.Size = UDim2.new(1,0,1.3,0)
  582.             f.Position = UDim2.new(0,0,-0.3,0)
  583.             f.BackgroundColor3 = Color3.new(0,0,0)
  584.             f.BorderSizePixel = 0
  585.             f.BackgroundTransparency = 1
  586.             f.Parent = gui.Random
  587.            
  588.             local t = Instance.new("TextLabel")
  589.             t.Size = UDim2.new(1,0,1,0)
  590.             t.Position = UDim2.new(0.5,0,0.5,0)
  591.             t.AnchorPoint = Vector2.new(0.5,0.5)
  592.             t.BackgroundColor3 = Color3.new(0,0,0)
  593.             t.BorderSizePixel = 0
  594.             t.TextTransparency = 1
  595.             t.Text = args[1]
  596.             t.TextColor3 = Color3.new(1,1,1)
  597.             t.TextScaled = false
  598.             t.FontSize = Enum.FontSize.Size60
  599.             t.Font = Enum.Font.Cartoon
  600.             t.Parent = f
  601.  
  602.            
  603.             for i = 0,0.2,0.01 do
  604.                 f.BackgroundTransparency = f.BackgroundTransparency - i
  605.                 t.TextTransparency = t.TextTransparency - i
  606.                 wait()
  607.             end
  608.             wait(3)
  609.             for i = 0,0.2,0.01 do
  610.                 f.BackgroundTransparency = f.BackgroundTransparency + i
  611.                 t.TextTransparency = t.TextTransparency + i
  612.                 wait()             
  613.             end
  614.            
  615.             f:Destroy()
  616.         end
  617.     end)
  618. end
  619.  
  620. do --// On death
  621.     hum.Died:Connect(function()
  622.         wait(0.1)
  623.         if hum:FindFirstChild("Tag") and hum:FindFirstChild("Tag").Killer.Value then
  624.             c.CameraSubject = hum:FindFirstChild("Tag").Killer.Value.Character.HumanoidRootPart
  625.             local btm = game.ReplicatedStorage.Assets.UI.Btm:Clone()
  626.             btm.Title.Text = "Killed by: "..hum.Tag.Killer.Value.Name
  627.             local top = game.ReplicatedStorage.Assets.UI.Top:Clone()
  628.             btm.Parent = player.PlayerGui.Main
  629.             top.Parent = btm.Parent
  630.             wait(6)
  631.             c.CameraSubject = char.HumanoidRootPart
  632.             btm:Destroy()
  633.             top:Destroy()
  634.         else
  635.             local btm = game.ReplicatedStorage.Assets.UI.Btm:Clone()
  636.             btm.Title.Text = "Killed by: Yourself?"
  637.             local top = game.ReplicatedStorage.Assets.UI.Top:Clone()
  638.             btm.Parent = player.PlayerGui.Main
  639.             top.Parent = btm.Parent
  640.             wait(6)
  641.             btm:Destroy()
  642.             top:Destroy()
  643.         end
  644.     end)
  645. end
  646.  
  647. -- lol done
Advertisement
Add Comment
Please, Sign In to add comment