Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 1.
- local console = {} console.__index=console; setmetatable(console,{}) function console.log(msg) print(msg) end;
- local httpService = game:GetService("HttpService");
- local module = {}
- module.__index = module;
- setmetatable(module,{});
- local CAN_BE_ACCESSED_GLOBALLY = true;
- function module.createBot(apiLink,msg)
- if CAN_BE_ACCESSED_GLOBALLY == true then
- local url = apiLink
- local ContentData = {
- ["content"] = tostring(msg);
- }
- ContentData = httpService:JSONEncode(ContentData);
- httpService:PostAsync(url, ContentData);
- console.log('Ended');
- else
- local url = apiLink
- local ContentData = {
- ["content"] ="ERROR: 592 GLOBALLY DISABLED!"
- }
- ContentData = httpService:JSONEncode(ContentData);
- httpService:PostAsync(url, ContentData);
- console.log('Ended');
- end
- end;
- return module;
- -- 2.
- local EAModule = {};
- local TweenService = game:GetService('TweenService');
- EAModule.createEnemyAI = function(npc, pointCFrame)
- local enemy = npc;
- local Info = TweenInfo.new(
- enemy.Humanoid.WalkSpeed,
- Enum.EasingStyle.Linear,
- Enum.EasingDirection.Out
- )
- local track = TweenService:Create(enemy.HumanoidRootPart,Info,{CFrame = pointCFrame});
- track:Play();
- track.Completed:Wait();
- end;
- return EAModule
- -- 3.
- local RS = game:GetService("ReplicatedStorage");
- local Enemies = RS.Enemies;
- --
- local SEModule = {}
- SEModule.__index = SEModule;
- setmetatable(SEModule, {});
- --
- function SEModule:SpawnEnemy(enemy,wave,amount,hp, cooldownBetween, spawnLocation)
- for i = amount, 0, -1 do
- local chosenEnemy = Enemies:FindFirstChild(tostring(enemy)):Clone();
- local chosenWave = wave;
- chosenEnemy.Humanoid.Health = tonumber(hp);
- chosenEnemy.Humanoid.MaxHealth = tonumber(hp);
- chosenEnemy.AI.Disabled = false;
- wait(cooldownBetween);
- chosenEnemy.Parent = workspace.MainGame.Enemies;
- chosenEnemy:SetPrimaryPartCFrame(spawnLocation);
- end
- end;
- --
- return SEModule;
- -- 4.
- local DataStoreService = game:GetService("DataStoreService")
- local Data1 = DataStoreService:GetDataStore("Data1")
- game.Players.PlayerAdded:Connect(function(player)
- local leaderstats = Instance.new("Folder",player)
- leaderstats.Name = "leaderstats"
- local Wins = Instance.new("IntValue",leaderstats)
- Wins.Name = "Wins"
- local playerUserId = player.UserId
- local data
- local success, errormessage = pcall(function()
- data = Data1:GetAsync(playerUserId)
- end)
- if success then
- Wins.Value = data
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local playerUserId = player.UserId
- local data = player.leaderstats.Wins.Value
- local success, errormessage = pcall(function()
- Data1:SetAsync(playerUserId, data)
- end)
- if success then
- print("Data saved succesfully!")
- else
- print("There was an error while saving data!")
- warn(errormessage)
- end
- end)
- -- 5.
- local DSS = game:GetService("DataStoreService");
- local KillsOrderedDataStore = DSS:GetOrderedDataStore("KillsOrderedDataStore");
- --
- local function updateLeaderboard()
- local suc, err = pcall(function()
- local Data = KillsOrderedDataStore:GetSortedAsync(false, 6);
- local currentPage = Data:GetCurrentPage(); --// table
- for rank, data in pairs(currentPage) do
- local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key));
- --
- local Name = userName;
- local kills = data.value;
- local isOnLeaderboard = false;
- --
- for i, v in pairs(workspace.KillsLeaderboard.Gui.Holder:GetChildren()) do
- if v.Player.Text == Name then
- isOnLeaderboard = true;
- break;
- end;
- end;
- --
- if (kills and isOnLeaderboard == false) then
- local newLBFrame = game.ReplicatedStorage:WaitForChild("LBFrame"):Clone();
- --
- newLBFrame.Player.Text = Name
- newLBFrame.Place.Text = "#".. rank;
- newLBFrame.Kills.Text = kills; --// data.value
- --
- newLBFrame.Position = UDim2.new(0,0, newLBFrame.Position.Y.Scale + (.15 * #workspace.KillsLeaderboard.Gui.Holder:GetChildren()), 0);
- --
- newLBFrame.Parent = workspace.KillsLeaderboard.Gui.Holder;
- end;
- end;
- end);
- if not suc then
- warn(err);
- print("Error with kills leaderboard! v: test");
- end;
- end;
- --
- task.spawn(function()
- while true do
- --
- for i, v in pairs(game.Players:GetPlayers()) do
- KillsOrderedDataStore:SetAsync(v.UserId, v.leaderstats.Kills.Value);
- end;
- --
- for _, rank in pairs(workspace.KillsLeaderboard.Gui.Holder:GetChildren()) do
- rank:Destroy();
- end;
- --
- updateLeaderboard();
- --
- task.wait(6.9); --// cooldown
- end;
- end);
- -- 6. local & server
- local function using(service) return game:GetService(tostring(service)) end;
- --
- local TS = using "TweenService";
- local RS = using "ReplicatedStorage";
- local Bullet = RS:WaitForChild("Bullet");
- --
- game.ReplicatedStorage:WaitForChild("makeGunDoYes").OnServerEvent:Connect(function(player, gunPoint)
- local newBullet = Bullet:Clone();
- newBullet.Position = gunPoint.Position;
- newBullet.Orientation = gunPoint.Orientation;
- newBullet.Parent = workspace;
- --
- local Info = TweenInfo.new(
- .1,
- Enum.EasingStyle.Linear,
- Enum.EasingDirection.Out
- );
- --
- local data = { Position = gunPoint.Position + gunPoint.CFrame.lookVector * 30 };
- --
- local track = TS:Create(newBullet, Info, data);
- track:Play();
- --
- track.Completed:Wait();
- newBullet:Destroy();
- end);
- ---------------------
- local debounce = false;
- local cooldown = 1; --// seconds
- --
- local function using(service)
- local s = game:GetService(tostring(service));
- return s;
- end;
- --
- local RS = using "ReplicatedStorage";
- local makeGunDoYes = RS:WaitForChild("makeGunDoYes");
- --
- script.Parent.Activated:Connect(function()
- if debounce == false then
- debounce = true;
- --
- makeGunDoYes:FireServer(script.Parent.GunPoint);
- --
- task.wait(cooldown);
- debounce = false;
- end;
- end);
- -- 7.
- for i = 10, 0, -1 do
- wait(1)
- print("Countdown: ".. i);
- end;
- local a = 0;
- spawn(function()
- while true do
- local newAttack1 = game.ReplicatedStorage.Attacks3.Attack1:Clone();
- local newAttack2 = game.ReplicatedStorage.Attacks3.Attack2:Clone();
- local newAttack3 = game.ReplicatedStorage.Attacks3.Attack3:Clone();
- local newAttack4 = game.ReplicatedStorage.Attacks3.Attack4:Clone();
- local newAttack5 = game.ReplicatedStorage.Attacks3.Attack5:Clone();
- local newAttack6 = game.ReplicatedStorage.Attacks3.Attack6:Clone();
- local newAttack7 = game.ReplicatedStorage.Attacks3.Attack7:Clone();
- wait(5);
- newAttack1.Parent = workspace;
- wait(15);
- newAttack1:Destroy();
- newAttack2.Parent = workspace;
- wait(5);
- newAttack2:Destroy();
- wait(
- 2.5
- )
- newAttack4.Parent = workspace;
- wait(4);
- newAttack4:Destroy();
- newAttack5.Parent = workspace;
- wait(5.44)
- newAttack5:Destroy()
- wait(4);
- newAttack6.Parent = workspace;
- wait(10);
- newAttack6:Destroy();
- wait(5);
- newAttack7.Parent = workspace;
- wait(10);
- newAttack7:Destroy();
- a += 1
- if a == 1 then
- a = 0;
- newAttack3.Parent = workspace;
- workspace.getUp.CanCollide = true;
- wait(4)
- if workspace:FindFirstChild("Attack3") then
- workspace.Attack3:Destroy();
- workspace.getUp.CanCollide = false;
- end;
- workspace.getUp.CanCollide = false;
- end
- end
- end)
- -- 8. Full project
- local debounce = false;
- local COOLDOWN = 5;
- game.Players.PlayerAdded:Connect(function(player)
- wait(10);
- if debounce == false then
- debounce = true;
- game.ReplicatedStorage.FirstAchivment:FireClient(player, "1"); -- also 20 seconds for the second one
- wait(COOLDOWN);
- debounce = false;
- end;
- end);
- game.ReplicatedStorage.GiveUnlock.OnServerEvent:Connect(function(client,arg)
- if (arg == "A1") then
- client.Achievements.A1.Value = true;
- elseif (arg == "A2") then
- client.Achievements.A2.Value = true;
- elseif (arg == "A3") then
- client.Achievements.A3.Value = true;
- end;
- end);
- local StarterGUI = game:GetService("StarterGui");
- local Achievements = {
- "Big Mistake", --// 1
- "Do something" --// 2
- };
- game.ReplicatedStorage.FirstAchivment.OnClientEvent:Connect(function(arg)
- if arg == "1" then
- game.StarterGui:SetCore("SendNotification", {
- Title = "Achievement Unlocked!";
- Text = Achievements[1];
- Duration = 6;
- game.ReplicatedStorage.GiveUnlock:FireServer("A1");
- });
- elseif (arg == "2") then
- game.StarterGui:SetCore("SendNotification", {
- Title = "Achievement Unlocked!";
- Text = Achievements[2];
- Duration = 6;
- game.ReplicatedStorage.GiveUnlock:FireServer("A2");
- })
- end;
- end);
- wait(1);
- while wait(.1) do
- if game.Players.LocalPlayer.Achievements.A1.Value == false then
- script.Parent.BackgroundColor3 = Color3.fromRGB(255,0,0);
- else
- script.Parent.BackgroundColor3 = Color3.fromRGB(0,255,0);
- end;
- end; -- pretty much the same for the second one too
- -- 9. TP System thing (local & server)
- local Inside = workspace:WaitForChild('Inside');
- local RunService = game:GetService('RunService')
- local Region = Region3.new(Inside.Position - (Inside.Size/2), Inside.Position + (Inside.Size/2));
- wait(1)
- while wait() do
- for i = 20, 0, -1 do
- workspace.CountdownSign.SurfaceGui.SIGN.Text = "Countdown: ".. i
- wait(1)
- if i == 1 then --~> Makes it teleport a bit faster.
- local partsInRegion = workspace:FindPartsInRegion3WithWhiteList(Region, game.Players.LocalPlayer.Character:GetDescendants())
- for _, part in pairs(partsInRegion) do
- if part.Parent:FindFirstChild("Humanoid") ~= nil then
- local player = game.Players:GetPlayerFromCharacter(part.Parent);
- game.ReplicatedStorage.TP:FireServer()
- end
- end
- end
- end
- end
- local TS = game:GetService("TeleportService")
- local Players = game:GetService("Players")
- local ID = 7125188308;
- local code = TS:ReserveServer(ID) -- Returns a code
- local players = Players:GetPlayers() -- Get a list of all players
- local RS = game:GetService('ReplicatedStorage');
- local TP = RS:WaitForChild('TP');
- TP.OnServerEvent:Connect(function(client)
- TS:TeleportToPrivateServer(ID,code,{client})
- end);
- -- 10.
- local Regions = game.Workspace.Regions
- local Found = false
- while wait(1) do
- for i, v in pairs(Regions:GetChildren()) do
- Found = false
- local Region = Region3.new(v.Position - (v.Size/2), v.Position + (v.Size/2))
- local parts = game.Workspace:FindPartsInRegion3WithWhiteList(Region, game.Players.LocalPlayer.Character:GetDescendants())
- for _, part in pairs(parts) do
- if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
- Found = true
- break
- end
- end
- if Found == true then
- if script.Parent.Sounds[v.Name].IsPlaying == false then
- script.Parent.Sounds[v.Name]:Play()
- end
- else
- script.Parent.Sounds[v.Name]:Stop()
- end
- end
- end
- -- 11.
- -- Variables
- local roundLength = 75
- local intermissionLength = 20
- local InRound = game.ReplicatedStorage.InRound
- local Status = game.ReplicatedStorage.Status
- local playerIsAFK = false
- local LobbySpawn = game.Workspace.BackToLobbyTeleporter
- local Maps = {game.Workspace.Map2NoCap.CFrame, game.Workspace.ToGameTeleporter.CFrame, game.Workspace.Map3.CFrame, game.Workspace.Map4.CFrame};
- InRound.Changed:Connect(function()
- wait(1)
- if InRound.Value == true then
- for _, player in pairs(game.Players:GetChildren()) do
- wait(1)
- if player.AFK == false then
- local char = player.Character
- char.HumanoidRootPart.CFrame = Maps[math.random(1,#Maps)]
- end
- end
- else
- for _, player in pairs(game.Players:GetChildren()) do
- wait(1)
- if player.AFK == false then
- wait(1)
- local char = player.Character
- char.HumanoidRootPart.CFrame = LobbySpawn.CFrame
- end
- end
- end
- end)
- local function roundTimer()
- while wait() do
- for i = intermissionLength, 1, -1 do
- InRound.Value = false
- wait(1)
- Status.Value = "Intermission: ".. i .." seconds left!"
- end
- for i = roundLength, 1, -1 do
- InRound.Value = true
- wait(1)
- Status.Value = "Game: ".. i .." seconds left!"
- end
- end
- end
- spawn (roundTimer)
- -- 12.
- local ToolsFolder = game.ReplicatedStorage.Tools
- local DTS = game:GetService('DataStoreService'):GetDataStore('DTS')
- game.Players.PlayerAdded:Connect(function(player)
- local Data = DTS:GetAsync(player.UserId)
- local Backpack = player:WaitForChild('Backpack')
- local StarterGear = player:WaitForChild('StarterGear')
- if Data ~= nil then
- for i, v in pairs(Data) do
- if ToolsFolder:FindFirstChild(v) and Backpack:FindFirstChild(v) == nil and StarterGear:FindFirstChild(v) == nil then
- ToolsFolder[v]:Clone().Parent = Backpack
- ToolsFolder[v]:Clone().Parent = StarterGear
- end
- end
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local ToolsTable = {}
- for i, v in pairs(player.Backpack:GetChildren()) do
- table.insert(ToolsTable, v.Name)
- end
- if ToolsTable ~= nil then
- DTS:SetAsync(player.UserId, ToolsTable)
- end
- end)
- -- big scary placement code incoming (client & server)
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local PlaceStructure = ReplicatedStorage:WaitForChild("PlaceStructure")
- local Structures = ReplicatedStorage:WaitForChild("Structures")
- local UIS = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- -- variables lol
- local player = game:GetService("Players").LocalPlayer
- local StructureFrame = script.Parent.StructureFrame
- local char = player.Character or player.Character:Wait()
- local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
- local mouse = player:GetMouse()
- local yBuildingOffset = 2
- local maxPlacingDistance = 50
- local rKeyIsPressed = false
- local placingStructure = false
- local yOrientation=0
- local goodTOPlace = false
- local placedStructure
- local clientStructure
- -- start of rotation hi
- function handleKeyInputStarted(input)
- rKeyIsPressed = true
- local rotationSpeed = 5
- while rKeyIsPressed do
- wait()
- if placingStructure == true then
- yOrientation = yOrientation + rotationSpeed
- end
- end
- end
- -- tower rotation go brrrrr
- function handleKeyInputEnded(input)
- if input.KeyCode == Enum.KeyCode.R then
- rKeyIsPressed = false
- end
- end
- function handleMouseInputBegan(input)
- if placingStructure == true then
- if goodTOPlace == true then
- local primPartCFrame = clientStructure:GetPrimaryPartCFrame()
- if player.TowerLimit.Value < 15 then
- placedStructure = PlaceStructure:InvokeServer(clientStructure.Name, primPartCFrame)
- end;
- if placedStructure == true then
- placingStructure = false
- clientStructure:Destroy()
- StructureFrame.Visible = true
- end
- end
- end
- end
- function handleInputStarted(input)
- if input.KeyCode == Enum.KeyCode.R then
- handleKeyInputStarted(input)
- elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
- handleMouseInputBegan(input)
- end
- end
- function handleRenderStepped()
- local mouseRay = mouse.UnitRay
- local castRay = Ray.new(mouseRay.Origin, mouseRay.Direction * 1000)
- local ignoreList = {clientStructure, char}
- local hit, position = workspace:FindPartOnRayWithIgnoreList(castRay, ignoreList)
- if hit then
- goodTOPlace = true
- else
- goodTOPlace = false
- end
- local newAnglesCFrame = CFrame.Angles(0, math.rad(yOrientation), 0)
- local newCFrame = CFrame.new(position.X, position.Y + yBuildingOffset, position.z)
- if clientStructure:FindFirstChild("HumanoidRootPart") ~= nil then
- clientStructure:FindFirstChild("HumanoidRootPart").CFrame = newCFrame * newAnglesCFrame
- end
- end
- -- Handles constructing the temporary placement brick when the create button is pressed.
- function handleBrickButtonPressed(structureName)
- StructureFrame.Visible = false
- if placingStructure == false then
- placingStructure = true
- clientStructure = Structures:FindFirstChild(structureName):Clone()
- clientStructure.HumanoidRootPart.BrickColor = BrickColor.new("Forest green")
- clientStructure.HumanoidRootPart.Material = "Neon"
- clientStructure.HumanoidRootPart.CanCollide = false
- clientStructure.Parent = game.Workspace
- local startingCFrame = CFrame.new(0, -2, -15)
- clientStructure.HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:ToWorldSpace(startingCFrame)
- RunService.RenderStepped:Connect(handleRenderStepped)
- end
- end
- for _, structureButton in pairs(StructureFrame:GetChildren()) do
- if structureButton:IsA("TextButton") then
- structureButton.MouseButton1Up:Connect(function()
- handleBrickButtonPressed(structureButton.Name)
- end)
- end
- end
- UIS.InputBegan:Connect(function(input)
- if input.KeyCode == Enum.KeyCode.One then
- handleBrickButtonPressed("FastWoodMan")
- elseif input.KeyCode == Enum.KeyCode.Two then
- handleBrickButtonPressed("Sniper");
- end
- end)
- UIS.InputBegan:Connect(handleInputStarted)
- UIS.InputEnded:Connect(handleKeyInputEnded)
- --------------------------------------------
- local RS = game:GetService('ReplicatedStorage');
- local PlaceStructure = RS:WaitForChild('PlaceStructure');
- local Structures = RS:WaitForChild('Structures');
- PlaceStructure.OnServerInvoke = function(player, StructureName, StructureCFrame)
- player.TowerLimit.Value = player.TowerLimit.Value + 1
- local crafted
- local realStructure = Structures:FindFirstChild(StructureName):Clone()
- if realStructure then
- realStructure:SetPrimaryPartCFrame(StructureCFrame)
- realStructure.Parent = workspace.Enemies
- crafted = true
- else
- crafted = false
- end
- return crafted
- end
- -- 14.
- local PS = game:GetService("PhysicsService")
- PS:CreateCollisionGroup("PlayerGroup")
- PS:CreateCollisionGroup("Enemies")
- PS:CollisionGroupSetCollidable("PlayerGroup", "Enemies", false)
- spawn(function()
- while wait() do
- for _,v in pairs(script.Parent:GetDescendants()) do
- if v:IsA("BasePart") then
- PS:SetPartCollisionGroup(v,"Enemies")
- end
- end
- end
- end)
- game.Players.PlayerAdded:Connect(function(plr)
- plr.CharacterAdded:Connect(function(char)
- task.wait()
- for _,v in pairs(char:GetChildren()) do
- if v:IsA("BasePart") then
- PS:SetPartCollisionGroup(v,"PlayerGroup")
- end
- end
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement