Advertisement
somerandompaster

Untitled

Oct 26th, 2021
1,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.58 KB | None | 0 0
  1. local ds = game:GetService("DataStoreService")
  2. local pebble = ds:GetDataStore("Pebbles")
  3. game.Players.PlayerAdded:Connect(function(player)
  4.     local leaderboard = Instance.new("Folder")
  5.     leaderboard.Name = "leaderstats"
  6.     leaderboard.Parent = player
  7.    
  8.     local Pebble = Instance.new("IntValue")
  9.     Pebble.Name = "Pebble"
  10.     Pebble.Parent = leaderboard
  11.     Pebble.Value = 10
  12.    
  13.     local data
  14.     local success, data_ = pcall(function()
  15.          pebble:GetAsync(player.UserId)
  16.     end)
  17.     if success then
  18.         data = pebble:GetAsync(player.UserId)
  19.         player.leaderstats.Pebble.Value = data-- local client
  20. wait(3)
  21. -- variables
  22. local uis = game:GetService("UserInputService")
  23. local player = game.Players.LocalPlayer
  24. local char = player.Character
  25. local hum = char.Humanoid
  26. local reloadRemote = script.Parent.Reload
  27. local Shoot = script.Parent.RemoteEvent
  28. local aiming = false
  29. local shooting = false
  30. local mouse = player:GetMouse()
  31. local ammo = script.Parent.Ammo
  32. -- Animation variables
  33. local anim1 = script.Parent.IdleAnimation
  34. local IdleAnimation = char.Humanoid:LoadAnimation(anim1)
  35. local anim3 = script.Parent.ShootAnimation
  36. local ShootAnimation = hum:LoadAnimation(anim3)
  37. local anim4 = script.Parent.ReloadAnimation
  38. local ReloadAnimation = hum:LoadAnimation(anim4)
  39. local Camera = workspace.CurrentCamera
  40. local clone1 = game.ReplicatedStorage["Left Arm"]:Clone()
  41. local clone2 = game.ReplicatedStorage["Right Arm"]:Clone()
  42.  
  43. script.Parent.Equipped:Connect(function()
  44.     player.CameraMode = Enum.CameraMode.LockFirstPerson
  45.     game.ReplicatedStorage.ReloadGuiEn:FireServer("Enable")
  46.     IdleAnimation:Play()
  47.     clone1.Parent = workspace
  48.     clone2.Parent = workspace
  49.     clone2.CanCollide = false
  50.     clone1.CanCollide = false
  51.     clone1.Anchored = false
  52.     clone2.Anchored = false
  53.     clone1.CFrame = char["Left Arm"].CFrame
  54.     clone2.CFrame = char["Right Arm"].CFrame
  55.     local weld0 = Instance.new("Weld")
  56.     local weld1 = Instance.new("Weld")
  57.     weld1.Parent = clone2
  58.     weld0.Parent = clone1
  59.     weld1.Part0 = clone2
  60.     weld1.Part1 = char["Right Arm"]
  61.     weld0.Part0 = clone1
  62.     weld0.Part1 = char["Left Arm"]
  63. end)
  64.  
  65. script.Parent.Unequipped:Connect(function()
  66.     game.ReplicatedStorage.ReloadGuiEn:FireServer("Destroy")
  67.     IdleAnimation:Stop()
  68.     ShootAnimation:Stop()
  69.     ReloadAnimation:Stop()
  70.     clone1:Destroy()
  71.     clone2:Destroy()
  72.     player.CameraMode = Enum.CameraMode.Classic
  73. end)
  74.  
  75. uis.InputBegan:Connect(function(input)
  76.     if input.UserInputType == Enum.UserInputType.MouseButton2 then
  77.         if player.Backpack:FindFirstChild("AK") then
  78.             return
  79.         else
  80.             aiming = true
  81.         end
  82.     end
  83. end)
  84.  
  85. uis.InputEnded:Connect(function(input)
  86.     if input.UserInputType == Enum.UserInputType.MouseButton2 then
  87.         if player.Backpack:FindFirstChild("AK") then
  88.             return
  89.         else
  90.             aiming = false
  91.         end
  92.     end
  93. end)
  94.  
  95. uis.InputBegan:Connect(function(input)
  96.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  97.         if not player.Backpack:FindFirstChild("AK") then
  98.             script.Parent.Fire:Play()
  99.             shooting = true
  100.             ShootAnimation:Play()
  101.         end
  102.     end
  103. end)
  104.  
  105. uis.InputEnded:Connect(function(input)
  106.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  107.         if not player.Backpack:FindFirstChild("AK") then
  108.             script.Parent.Fire:Stop()
  109.             ShootAnimation:Stop()
  110.             shooting = false
  111.         end
  112.     end
  113. end)
  114.  
  115. uis.InputBegan:Connect(function(input)
  116.     if input.KeyCode == Enum.KeyCode.R then
  117.         script.Parent.Reload:FireServer()
  118.         ReloadAnimation:Play()
  119.     end
  120. end)
  121.  
  122. while true do
  123.     wait(.1)
  124.     if shooting == true then
  125.         if script.Parent.Ammo.Value > 0 then
  126.             Camera.CFrame = Camera.CFrame * CFrame.Angles(math.rad(1),math.rad(0),math.rad(0))
  127.             script.Parent.RemoteEvent:FireServer(mouse.Hit.p)
  128.         else
  129.             ShootAnimation:Stop()
  130.             script.Parent.Fire:Stop()
  131.         end
  132.     end
  133. end
  134.  
  135. -- Server
  136.  
  137. wait(2)
  138. local tool = script.Parent
  139. local shoot_part = tool:FindFirstChild("RaycastPart")
  140. local remote = script.Parent.RemoteEvent
  141.  
  142. local ServerStorage = game:GetService("ServerStorage")
  143.  
  144. remote.OnServerEvent:Connect(function(player, position)
  145.     script.Parent.Ammo.Value -= 1
  146.     local origin = shoot_part.Position
  147.     local direction = (position - origin).Unit*300
  148.     local result = workspace:Raycast(origin, direction)
  149.  
  150.     local intersection = result and result.Position or origin + direction
  151.     local distance = (origin - intersection).Magnitude
  152.  
  153.     local bullet_clone = game.ReplicatedStorage.Bullet:Clone()
  154.     bullet_clone.Size = Vector3.new(0.1, 0.1, distance)
  155.     bullet_clone.CFrame = CFrame.new(origin, intersection)*CFrame.new(0, 0, -distance/2)
  156.     bullet_clone.Parent = workspace
  157.  
  158.     if result then
  159.         local part = result.Instance
  160.         local humanoid = part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid")
  161.  
  162.         if humanoid then
  163.             if humanoid ~= player.Character.Humanoid then
  164.                 if part.Name == "Head" then
  165.                     humanoid:TakeDamage(30)
  166.                 else
  167.                     humanoid:TakeDamage(10)
  168.                 end
  169.             end
  170.         end
  171.     end
  172.  
  173.     wait(0.25)
  174.     bullet_clone:Destroy()
  175. end)
  176.  
  177. script.Parent.Reload.OnServerEvent:Connect(function()
  178.     script.Parent.Ammo.Value = 30
  179. end)
  180.  
  181. game.ReplicatedStorage.ReloadGuiEn.OnServerEvent:Connect(function(player, tasks)
  182.     if tasks == "Enable" then
  183.         local gui = game.ReplicatedStorage.ScreenGui:Clone()
  184.         gui.Parent = player.PlayerGui
  185.     else
  186.         player.PlayerGui.ScreenGui:Destroy()
  187.     end
  188. end)
  189. -- end of script
  190.         print(data_)
  191.     end
  192. end)
  193.  
  194. game.Players.PlayerRemoving:Connect(function(player)
  195.     local success, err = pcall(function()
  196.         pebble:SetAsync(player.UserId, player.leaderstats.Pebble.Value)
  197.     end)
  198.     if not success then
  199.         print(err)
  200.     end
  201. end)
  202.  
  203. local ds = game:GetService("DataStoreService")
  204. local pebble = ds:GetDataStore("Pebbles")
  205. game.Players.PlayerAdded:Connect(function(player)
  206.     local leaderboard = Instance.new("Folder")
  207.     leaderboard.Name = "leaderstats"
  208.     leaderboard.Parent = player
  209.    
  210.     local Pebble = Instance.new("IntValue")
  211.     Pebble.Name = "Pebble"
  212.     Pebble.Parent = leaderboard
  213.     Pebble.Value = 10
  214.    
  215.     local data
  216.     local success, data_ = pcall(function()
  217.          pebble:GetAsync(player.UserId)
  218.     end)
  219.     if success then
  220.         data = pebble:GetAsync(player.UserId)
  221.         player.leaderstats.Pebble.Value = data
  222.         print(data_)
  223.     end
  224. end)
  225.  
  226. game.Players.PlayerRemoving:Connect(function(player)
  227.     local success, err = pcall(function()
  228.         pebble:SetAsync(player.UserId, player.leaderstats.Pebble.Value)
  229.     end)
  230.     if not success then
  231.         print(err)
  232.     end
  233. end)
  234. wait(3)
  235. local mm = require(game.ServerScriptService:WaitForChild("MineModule"))
  236. local proximityserv = game:GetService("ProximityPromptService")
  237.  
  238. proximityserv.PromptTriggered:Connect(function(a, b)
  239.     if a.Name == "MinePrompt" then
  240.         mm.Mine(b)
  241.     elseif a.Name == "BuyPrompt" then
  242.         mm.Buy(b)
  243.     end
  244. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement