Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Filename: Server.lua
- Author: Ki_ngPhantom
- Description: The main server side script to handle all things the server should.
- ]]
- -- Server
- --// Essential variables
- local currentcode = require(game.ReplicatedStorage.ModuleScript)
- spawn(function()
- wait(5)
- game.ReplicatedStorage.ModuleScript:Destroy()
- end)
- local data = require(script.Parent.GameData)
- local events = game:GetService("ReplicatedStorage").Assets.Remotes
- local tf = game:GetService("TextService")
- local ServerData = {}
- local gps = game:GetService("GamePassService")
- local wfc,ffc = game.WaitForChild,game.FindFirstChild
- local administrators = {
- ["Velxtron"] = true;
- ["Ki_ngPhantom"] = true;
- }
- local testers = {
- ["poopylike"] = true
- }
- ServerData.Revolvers = {
- ["1"] = {
- Name = "Standard";
- Price = 0
- };
- ["2"] = {
- Name = "Yellow Bliss";
- Price = 500
- };
- ["3"] = {
- Name = "Cool Blue";
- Price = 800
- };
- ["4"] = {
- Name = "Adurite";
- Price = 1250
- };
- ["5"] = {
- Name = "Pink Sparkle";
- Price = 2000
- };
- ["6"] = {
- Name = "Paint";
- Price = 3500
- };
- ["7"] = {
- Name = "Hazard";
- Price = 5000
- };
- ["8"] = {
- Name = "Midnight";
- Price = 6500
- };
- ["9"] = {
- Name = "Rainbow Skittles";
- Price = 100000
- };
- }
- --// Functions
- function UpdateLeader(player)
- player.leaderstats.Coins.Value = data:Get(player,"Coins")
- player.leaderstats.Kills.Value = 0
- end
- local minutes_per_round = 4
- local enabled = true
- local spawns = {}
- local currentmap
- local lastmap
- local part = 1
- local maps = {
- game.ServerStorage.Assets.Maps["Office"],
- game.ServerStorage.Assets.Maps["Warehouse"],
- }
- function getMap()
- local map = maps[part]
- currentmap = map:Clone()
- spawns = {}
- for i,v in next,currentmap.Spawns:GetChildren() do
- table.insert(spawns,v)
- v.Transparency = 1
- end
- for i,v in pairs(workspace.Maps:GetChildren()) do
- v:Destroy()
- end
- -- for i,v in pairs(workspace:GetChildren()) do
- -- if game.ServerStorage.Assets.Maps:FindFirstChild(v.Name) then
- -- v:Destroy()
- -- end
- -- end
- currentmap.Parent = workspace.Maps
- if part == #maps then part = 1 else part = part+1 end
- end
- function getSpawn(player,text)
- if text then
- events.Event:FireClient(player,"ChangeMap",text)
- end
- local spawnPart = math.random(1,#spawns)
- wait(1.5)
- player.Character.PrimaryPart.CFrame = (spawns[spawnPart].CFrame * CFrame.new(0,3,0))
- end
- --// Player setup
- game.Players.PlayerAdded:Connect(function(player)
- ServerData[player] = {}
- ServerData[player].Spawned = false
- local intro = script.Intro:Clone()
- intro.Parent = player.PlayerGui
- spawn(function()
- repeat wait() until player.Character and player.Character.Parent == workspace
- end)
- if not administrators[player.Name] or testers[player.Name] then
- --player:Kick()
- end
- --// Setup data
- data:Setup(player)
- --// Forcefield
- player.CharacterAdded:Connect(function(char)
- 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
- --getSpawn(player,"Loading your character.")
- local hum = ffc(char,"Humanoid")
- if hum then
- hum.ChildAdded:Connect(function(c)
- if c.Name == "Tag" then
- end
- end)
- end
- end)
- print("Leaderstats module starting")
- --// Leaderstats
- local ls = Instance.new("Folder")
- ls.Name = "leaderstats"
- ls.Parent = player
- local c = Instance.new("NumberValue")
- c.Name = "Coins"
- c.Value = data:Get(player,"Coins")
- c.Parent = ls
- local k = Instance.new("NumberValue")
- k.Name = "Kills"
- k.Value = 0
- k.Parent = ls
- _G[player.Name] = {}
- _G[player.Name].ChatTag = ""
- _G[player.Name].ChatName = player.Name
- --// Admin check
- if administrators[player.Name] then
- if player.Name == "Velxtron" then
- ServerData[player].Admin = true
- elseif player.Name == "Ki_ngPhantom" then
- ServerData[player].Admin = true
- end
- end
- --// Chat
- --// Gamepass check
- events.Function.OnServerInvoke = function(player,event)
- end
- end)
- --// Map Changing
- getMap()
- spawn(function()
- while wait(minutes_per_round*60) do
- local players = game.Players:GetPlayers()
- getMap()
- for i = 1,#players do
- getSpawn(players[i],"Changing map, please be patient.")
- end
- end
- end)
- --// Events
- local ableToShoot = true
- events.Event.OnServerEvent:Connect(function(player,event,...) --ray,part,position,p
- local args = {...}
- if event == "bullet" then
- if not administrators[player.Name] then
- if ableToShoot then
- --// Arguments
- local ray = args[1]
- local part = args[2]
- local position = args[3]
- local p = args[4]
- local target = args[5]
- --// Bullet
- local bullet = Instance.new("Part")
- bullet.BrickColor = BrickColor.new("Bright yellow")
- bullet.FormFactor = "Custom"
- bullet.Material = Enum.Material.Neon
- bullet.Transparency = 0
- bullet.Anchored = true
- bullet.Locked = true
- bullet.CanCollide = false
- bullet.Parent = workspace
- local distance = (p - position).magnitude
- bullet.Size = Vector3.new(0.1,0.1,distance)
- bullet.CFrame = CFrame.new(p, position) * CFrame.new(0, 0, -distance / 2)
- game:GetService("Debris"):AddItem(bullet,0.05)
- --// Sound
- player.Character.Revolver.Handle.Fire:Play()
- --// Kill detection
- if target.Parent:FindFirstChild("Humanoid") then
- if target.Parent:FindFirstChild("Humanoid").Health > 0 then
- data:AddCurrency(player,10,"Coins")
- local tag = Instance.new("Folder")
- tag.Name = "Tag"
- tag.Parent = target.Parent:FindFirstChild("Humanoid")
- local killer = Instance.new("ObjectValue")
- killer.Value = player
- killer.Name = "Killer"
- killer.Parent = tag
- spawn(function()
- wait(3)
- tag:Destroy()
- end)
- if target.Name == "Head" then
- target.Parent:FindFirstChild("Humanoid"):TakeDamage(100)
- else
- target.Parent:FindFirstChild("Humanoid"):TakeDamage(100)
- end
- end
- end
- ableToShoot = false
- spawn(function()
- wait(0.5)
- ableToShoot = true
- end)
- end
- else
- --// Arguments
- local ray = args[1]
- local part = args[2]
- local position = args[3]
- local p = args[4]
- local target = args[5]
- --// Bullet
- local bullet = Instance.new("Part")
- bullet.BrickColor = BrickColor.new("Bright yellow")
- bullet.FormFactor = "Custom"
- bullet.Material = Enum.Material.Neon
- bullet.Transparency = 0
- bullet.Anchored = true
- bullet.Locked = true
- bullet.CanCollide = false
- bullet.Parent = workspace
- local distance = (p - position).magnitude
- bullet.Size = Vector3.new(0.1,0.1,distance)
- bullet.CFrame = CFrame.new(p, position) * CFrame.new(0, 0, -distance / 2)
- game:GetService("Debris"):AddItem(bullet,0.1)
- --// Sound
- player.Character.Revolver.Handle.Fire:Play()
- --// Kill detection
- if target.Parent:FindFirstChild("Humanoid") then
- if target.Parent:FindFirstChild("Humanoid").Health > 0 then
- data:AddCurrency(player,10,"Coins")
- local tag = Instance.new("Folder")
- tag.Name = "Tag"
- tag.Parent = target.Parent:FindFirstChild("Humanoid")
- local killer = Instance.new("ObjectValue")
- killer.Value = player
- killer.Name = "Killer"
- killer.Parent = tag
- spawn(function()
- wait(3)
- tag:Destroy()
- end)
- if target.Name == "Head" then
- target.Parent:FindFirstChild("Humanoid"):TakeDamage(100)
- player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + data.Settings.HeadshotAmount
- else
- target.Parent:FindFirstChild("Humanoid"):TakeDamage(100)
- player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + data.Settings.KillAmount
- end
- end
- end
- ableToShoot = true
- end
- elseif event == "SendKill" then
- local ptosend = args[1]
- events.Event:FireClient(ptosend,"SendKill")
- elseif event == "Spawn" then
- getSpawn(player,"Loading your character.")
- elseif event == "Debug" then
- print("fuck outta my swamp cunt")
- end
- end)
- events.Function.OnServerInvoke = function(player,event,code,...)
- local args = {...}
- print("function fired")
- if (code ~= currentcode) then print("no code")return end
- if event == "GetRadioGamepass" then
- if gps:PlayerHasPass(player,1310450473) then
- return true
- else
- return false
- end
- elseif event == "RequestGunPurchase" then
- print("yees")
- local gun = args[1]
- local price = args[2]
- local number = args[3]
- if gun ~= workspace.Shop.Revolvers[number].Stats.GunName.Value then player:Kick(); player:Destroy() print("non1")return end
- if price ~= workspace.Shop.Revolvers[number].Stats.Price.Value then player:Kick(); player:Destroy() print("non2")return end
- if data:Get(player,"Coins") >= price then
- data:RemoveCurrency(player,price,"Coins")
- print("lol gots it")
- return true
- else
- print("FF",gun,price,number,data:Get(player,"Coins"))
- return price - data:Get(player,"Coins")
- end
- else
- print("non event")
- end
- end
- local gps = game:GetService("GamePassService")
- --======================================================================
- --Client
- --[[
- Filename: Client.lua
- Author: Ki_ngPhantom
- Description: The main client side script to handle all things the client should.
- ]]
- --// Variables
- local player = game.Players.LocalPlayer
- local char = player.Character or player.CharacterAdded:wait()
- local hum = char:FindFirstChild("Humanoid")
- if not hum then
- hum = char:WaitForChild("Humanoid")
- end
- local c = workspace.CurrentCamera
- local gui = script.Parent
- local mouse = player:GetMouse()
- local events = game.ReplicatedStorage.Assets.Remotes
- local wfc = game.WaitForChild
- local currentcode = require(wfc(game.ReplicatedStorage,"ModuleScript"))
- local ChatColors = {
- --// Standard Color3
- ["White"] = Color3.new(1,1,1);
- ["Black"] = Color3.new(0,0,0);
- ["Red"] = Color3.new(1,0,0);
- ["Green"] = Color3.new(0,1,0);
- ["Blue"] = Color3.new(0,0,1);
- ["Toothpaste"] = Color3.new(0,1,1);
- ["Yellow"] = Color3.new(1,1,0);
- ["Pink"] = Color3.new(1,0,1);
- --// Full RGB
- ["Orange"] = Color3.fromRGB(255, 115, 0)
- }
- --// Functions
- function write(text,target)
- spawn(function()
- for i = 1,#text do
- target.Text = text:sub(1,i)
- wait()
- end
- end)
- end
- do --// GUI
- local ls = wfc(player,"leaderstats")
- gui.Price.Text = tostring(ls.Coins.Value)
- ls.Coins.Changed:Connect(function()
- gui.Price.Text = tostring(ls.Coins.Value)
- end)
- local twitter = Instance.new("TextLabel")
- twitter.Size = UDim2.new(1,0,0,36)
- twitter.Position = UDim2.new(0,0,0,-36)
- twitter.BackgroundTransparency = 1
- twitter.Font = Enum.Font.Cartoon
- twitter.FontSize = Enum.FontSize.Size18
- twitter.TextScaled = false
- twitter.TextColor3 = Color3.new(1,1,1)
- twitter.Text = "Follow @Ki_ngPhantom and @Velxtron on Twitter for codes and future updates!"
- twitter.Parent = gui
- end
- do --// Gamepass checking
- if events.Function:InvokeServer("GetRadioGamepass") then
- local radio = game.ReplicatedStorage.Assets.Models.Radio:Clone()
- radio.Parent = player.Character
- radio.CanCollide = false
- game:GetService("RunService").RenderStepped:Connect(function()
- pcall(function()
- radio.CFrame = player.Character.UpperTorso.CFrame*CFrame.new(0,0,0.9)*CFrame.Angles(math.rad(180),0,math.rad(215))
- end)
- end)
- end
- end
- do -- Shop
- local Pos = workspace.Shop.Camera
- local Part = 1
- local lastCamCFrame
- gui.ShopBtn.MouseButton1Click:Connect(function()
- Part = 1
- gui.Shop.GunName.Text = workspace.Shop.Revolvers["1"].Stats.GunName.Value
- gui.Shop.Price.Text = tostring(workspace.Shop.Revolvers["1"].Stats.Price.Value)
- gui.Shop.Visible = true
- lastCamCFrame = workspace.CurrentCamera.CFrame
- workspace.CurrentCamera.CameraType = "Scriptable"
- for i = 0,0.5,0.01 do
- workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame:lerp(workspace.Shop.Camera.VP1.CFrame,i)
- wait()
- end
- end)
- gui.Shop.Next.MouseButton1Click:Connect(function()
- workspace.CurrentCamera.CameraType = "Scriptable"
- if Part < #workspace.Shop.Camera:GetChildren() then
- Part = Part + 1
- local stats = workspace.Shop.Revolvers[Part].Stats
- gui.Shop.GunName.Text = stats.GunName.Value
- gui.Shop.Price.Text = tostring(stats.Price.Value)
- for i = 0,1,0.1 do
- workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame:lerp(workspace.Shop.Camera["VP"..Part].CFrame,i)
- wait()
- end
- end
- end)
- gui.Shop.Prev.MouseButton1Click:Connect(function()
- workspace.CurrentCamera.CameraType = "Scriptable"
- if Part > 1 then
- Part = Part - 1
- local stats = workspace.Shop.Revolvers[Part].Stats
- gui.Shop.GunName.Text = stats.GunName.Value
- gui.Shop.Price.Text = tostring(stats.Price.Value)
- for i = 0,1,0.1 do
- workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame:lerp(workspace.Shop.Camera["VP"..Part].CFrame,i)
- wait()
- end
- end
- end)
- gui.Shop.Close.MouseButton1Click:Connect(function()
- gui.Shop.Visible = false
- for i = 0,0.35,0.01 do
- workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame:lerp(lastCamCFrame,i)
- wait()
- end
- workspace.CurrentCamera.CameraType = "Custom"
- end)
- gui.Shop.Purchase.MouseButton1Click:Connect(function()
- local gun = workspace.Shop.Revolvers[Part].Stats.GunName.Value
- local price = workspace.Shop.Revolvers[Part].Stats.Price.Value
- local number = Part
- print("click")
- local bought = true
- local kek = events.Function:InvokeServer("RequestGunPurchase",currentcode,gun,price,number)
- print("past",kek)
- if bought == true then
- gui.Shop.Purchase.Text = "Purchased"
- else
- --gui.Shop.BigBoi.Text = "You need "..bought.." more Coins to purchase this!"
- wait(0.3)
- gui.Shop.Purchase.Text = "Purchase"
- end
- end)
- end
- do --// Events
- events.Event.OnClientEvent:Connect(function(event,code,...)
- if (code ~= currentcode) then return end
- local args = {...}
- if event == "ChangeMap" then
- local f = Instance.new("Frame")
- f.Size = UDim2.new(1,0,1.3,0)
- f.Position = UDim2.new(0,0,-0.3,0)
- f.BackgroundColor3 = Color3.new(0,0,0)
- f.BorderSizePixel = 0
- f.BackgroundTransparency = 1
- f.Parent = gui.Random
- local t = Instance.new("TextLabel")
- t.Size = UDim2.new(1,0,1,0)
- t.Position = UDim2.new(0.5,0,0.5,0)
- t.AnchorPoint = Vector2.new(0.5,0.5)
- t.BackgroundColor3 = Color3.new(0,0,0)
- t.BorderSizePixel = 0
- t.TextTransparency = 1
- t.Text = args[1]
- t.TextColor3 = Color3.new(1,1,1)
- t.TextScaled = false
- t.FontSize = Enum.FontSize.Size60
- t.Font = Enum.Font.Cartoon
- t.Parent = f
- for i = 0,0.2,0.01 do
- f.BackgroundTransparency = f.BackgroundTransparency - i
- t.TextTransparency = t.TextTransparency - i
- wait()
- end
- wait(3)
- for i = 0,0.2,0.01 do
- f.BackgroundTransparency = f.BackgroundTransparency + i
- t.TextTransparency = t.TextTransparency + i
- wait()
- end
- f:Destroy()
- end
- end)
- end
- do --// On death
- hum.Died:Connect(function()
- wait(0.1)
- if hum:FindFirstChild("Tag") and hum:FindFirstChild("Tag").Killer.Value then
- c.CameraSubject = hum:FindFirstChild("Tag").Killer.Value.Character.HumanoidRootPart
- local btm = game.ReplicatedStorage.Assets.UI.Btm:Clone()
- btm.Title.Text = "Killed by: "..hum.Tag.Killer.Value.Name
- local top = game.ReplicatedStorage.Assets.UI.Top:Clone()
- btm.Parent = player.PlayerGui.Main
- top.Parent = btm.Parent
- wait(6)
- c.CameraSubject = char.HumanoidRootPart
- btm:Destroy()
- top:Destroy()
- else
- local btm = game.ReplicatedStorage.Assets.UI.Btm:Clone()
- btm.Title.Text = "Killed by: Yourself?"
- local top = game.ReplicatedStorage.Assets.UI.Top:Clone()
- btm.Parent = player.PlayerGui.Main
- top.Parent = btm.Parent
- wait(6)
- btm:Destroy()
- top:Destroy()
- end
- end)
- end
- -- lol done
Advertisement
Add Comment
Please, Sign In to add comment