Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ds = game:GetService("DataStoreService")
- local pebble = ds:GetDataStore("Pebbles")
- game.Players.PlayerAdded:Connect(function(player)
- local leaderboard = Instance.new("Folder")
- leaderboard.Name = "leaderstats"
- leaderboard.Parent = player
- local Pebble = Instance.new("IntValue")
- Pebble.Name = "Pebble"
- Pebble.Parent = leaderboard
- Pebble.Value = 10
- local data
- local success, data_ = pcall(function()
- pebble:GetAsync(player.UserId)
- end)
- if success then
- data = pebble:GetAsync(player.UserId)
- player.leaderstats.Pebble.Value = data-- local client
- wait(3)
- -- variables
- local uis = game:GetService("UserInputService")
- local player = game.Players.LocalPlayer
- local char = player.Character
- local hum = char.Humanoid
- local reloadRemote = script.Parent.Reload
- local Shoot = script.Parent.RemoteEvent
- local aiming = false
- local shooting = false
- local mouse = player:GetMouse()
- local ammo = script.Parent.Ammo
- -- Animation variables
- local anim1 = script.Parent.IdleAnimation
- local IdleAnimation = char.Humanoid:LoadAnimation(anim1)
- local anim3 = script.Parent.ShootAnimation
- local ShootAnimation = hum:LoadAnimation(anim3)
- local anim4 = script.Parent.ReloadAnimation
- local ReloadAnimation = hum:LoadAnimation(anim4)
- local Camera = workspace.CurrentCamera
- local clone1 = game.ReplicatedStorage["Left Arm"]:Clone()
- local clone2 = game.ReplicatedStorage["Right Arm"]:Clone()
- script.Parent.Equipped:Connect(function()
- player.CameraMode = Enum.CameraMode.LockFirstPerson
- game.ReplicatedStorage.ReloadGuiEn:FireServer("Enable")
- IdleAnimation:Play()
- clone1.Parent = workspace
- clone2.Parent = workspace
- clone2.CanCollide = false
- clone1.CanCollide = false
- clone1.Anchored = false
- clone2.Anchored = false
- clone1.CFrame = char["Left Arm"].CFrame
- clone2.CFrame = char["Right Arm"].CFrame
- local weld0 = Instance.new("Weld")
- local weld1 = Instance.new("Weld")
- weld1.Parent = clone2
- weld0.Parent = clone1
- weld1.Part0 = clone2
- weld1.Part1 = char["Right Arm"]
- weld0.Part0 = clone1
- weld0.Part1 = char["Left Arm"]
- end)
- script.Parent.Unequipped:Connect(function()
- game.ReplicatedStorage.ReloadGuiEn:FireServer("Destroy")
- IdleAnimation:Stop()
- ShootAnimation:Stop()
- ReloadAnimation:Stop()
- clone1:Destroy()
- clone2:Destroy()
- player.CameraMode = Enum.CameraMode.Classic
- end)
- uis.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton2 then
- if player.Backpack:FindFirstChild("AK") then
- return
- else
- aiming = true
- end
- end
- end)
- uis.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton2 then
- if player.Backpack:FindFirstChild("AK") then
- return
- else
- aiming = false
- end
- end
- end)
- uis.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- if not player.Backpack:FindFirstChild("AK") then
- script.Parent.Fire:Play()
- shooting = true
- ShootAnimation:Play()
- end
- end
- end)
- uis.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- if not player.Backpack:FindFirstChild("AK") then
- script.Parent.Fire:Stop()
- ShootAnimation:Stop()
- shooting = false
- end
- end
- end)
- uis.InputBegan:Connect(function(input)
- if input.KeyCode == Enum.KeyCode.R then
- script.Parent.Reload:FireServer()
- ReloadAnimation:Play()
- end
- end)
- while true do
- wait(.1)
- if shooting == true then
- if script.Parent.Ammo.Value > 0 then
- Camera.CFrame = Camera.CFrame * CFrame.Angles(math.rad(1),math.rad(0),math.rad(0))
- script.Parent.RemoteEvent:FireServer(mouse.Hit.p)
- else
- ShootAnimation:Stop()
- script.Parent.Fire:Stop()
- end
- end
- end
- -- Server
- wait(2)
- local tool = script.Parent
- local shoot_part = tool:FindFirstChild("RaycastPart")
- local remote = script.Parent.RemoteEvent
- local ServerStorage = game:GetService("ServerStorage")
- remote.OnServerEvent:Connect(function(player, position)
- script.Parent.Ammo.Value -= 1
- local origin = shoot_part.Position
- local direction = (position - origin).Unit*300
- local result = workspace:Raycast(origin, direction)
- local intersection = result and result.Position or origin + direction
- local distance = (origin - intersection).Magnitude
- local bullet_clone = game.ReplicatedStorage.Bullet:Clone()
- bullet_clone.Size = Vector3.new(0.1, 0.1, distance)
- bullet_clone.CFrame = CFrame.new(origin, intersection)*CFrame.new(0, 0, -distance/2)
- bullet_clone.Parent = workspace
- if result then
- local part = result.Instance
- local humanoid = part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid")
- if humanoid then
- if humanoid ~= player.Character.Humanoid then
- if part.Name == "Head" then
- humanoid:TakeDamage(30)
- else
- humanoid:TakeDamage(10)
- end
- end
- end
- end
- wait(0.25)
- bullet_clone:Destroy()
- end)
- script.Parent.Reload.OnServerEvent:Connect(function()
- script.Parent.Ammo.Value = 30
- end)
- game.ReplicatedStorage.ReloadGuiEn.OnServerEvent:Connect(function(player, tasks)
- if tasks == "Enable" then
- local gui = game.ReplicatedStorage.ScreenGui:Clone()
- gui.Parent = player.PlayerGui
- else
- player.PlayerGui.ScreenGui:Destroy()
- end
- end)
- -- end of script
- print(data_)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local success, err = pcall(function()
- pebble:SetAsync(player.UserId, player.leaderstats.Pebble.Value)
- end)
- if not success then
- print(err)
- end
- end)
- local ds = game:GetService("DataStoreService")
- local pebble = ds:GetDataStore("Pebbles")
- game.Players.PlayerAdded:Connect(function(player)
- local leaderboard = Instance.new("Folder")
- leaderboard.Name = "leaderstats"
- leaderboard.Parent = player
- local Pebble = Instance.new("IntValue")
- Pebble.Name = "Pebble"
- Pebble.Parent = leaderboard
- Pebble.Value = 10
- local data
- local success, data_ = pcall(function()
- pebble:GetAsync(player.UserId)
- end)
- if success then
- data = pebble:GetAsync(player.UserId)
- player.leaderstats.Pebble.Value = data
- print(data_)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local success, err = pcall(function()
- pebble:SetAsync(player.UserId, player.leaderstats.Pebble.Value)
- end)
- if not success then
- print(err)
- end
- end)
- wait(3)
- local mm = require(game.ServerScriptService:WaitForChild("MineModule"))
- local proximityserv = game:GetService("ProximityPromptService")
- proximityserv.PromptTriggered:Connect(function(a, b)
- if a.Name == "MinePrompt" then
- mm.Mine(b)
- elseif a.Name == "BuyPrompt" then
- mm.Buy(b)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement