Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Converted with ttyyuu12345's model to script plugin v4
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- Tool0 = Instance.new("Tool")
- Sound1 = Instance.new("Sound")
- NumberValue2 = Instance.new("NumberValue")
- Animation3 = Instance.new("Animation")
- Animation4 = Instance.new("Animation")
- ScreenGui5 = Instance.new("ScreenGui")
- TextLabel6 = Instance.new("TextLabel")
- LocalScript7 = Instance.new("LocalScript")
- TextLabel8 = Instance.new("TextLabel")
- LocalScript9 = Instance.new("LocalScript")
- Animation10 = Instance.new("Animation")
- Part11 = Instance.new("Part")
- Script12 = Instance.new("Script")
- Tool0.Name = "Deagle"
- Tool0.Parent = mas
- Tool0.GripForward = Vector3.new(-0.999229848, -0.0209334791, -0.0331904814)
- Tool0.GripPos = Vector3.new(2.00845313, -0.593266726, -0.0581263378)
- Tool0.GripRight = Vector3.new(0.0327064507, 0.023055179, -0.999199033)
- Tool0.GripUp = Vector3.new(-0.0216819271, 0.999515057, 0.0223527625)
- Sound1.Name = "Gunfire"
- Sound1.Parent = Tool0
- NumberValue2.Name = "Bullets"
- NumberValue2.Parent = Tool0
- NumberValue2.Value = 35
- Animation3.Name = "reload"
- Animation3.Parent = Tool0
- Animation3.AnimationId = "rbxassetid://1132295325"
- Animation4.Name = "shoot"
- Animation4.Parent = Tool0
- Animation4.AnimationId = "rbxassetid://1133088820"
- ScreenGui5.Name = "GunGUI"
- ScreenGui5.Parent = Tool0
- TextLabel6.Name = "Bullets"
- TextLabel6.Parent = ScreenGui5
- TextLabel6.Transparency = 0.60000002384186
- TextLabel6.Size = UDim2.new(0, 200, 0, 50)
- TextLabel6.Text = "NiL/NiL"
- TextLabel6.Position = UDim2.new(0.5, -100, 0.800000012, -25)
- TextLabel6.BackgroundColor3 = Color3.new(0, 0, 0)
- TextLabel6.BackgroundTransparency = 0.60000002384186
- TextLabel6.BorderSizePixel = 0
- TextLabel6.SizeConstraint = Enum.SizeConstraint.RelativeYY
- TextLabel6.Font = Enum.Font.SciFi
- TextLabel6.FontSize = Enum.FontSize.Size48
- TextLabel6.TextColor3 = Color3.new(1, 1, 1)
- TextLabel6.TextScaled = true
- TextLabel6.TextWrapped = true
- LocalScript7.Parent = TextLabel6
- table.insert(cors,sandbox(LocalScript7,function()
- local bullets = game.Workspace:WaitForChild(game.Players.LocalPlayer.Name) :WaitForChild("Deagle").Bullets
- script.Parent.Text = bullets.Value.."/35"
- bullets.Changed:Connect(function()
- if bullets.Value == 0 then
- script.Parent.Text = "Press 'r' to reload"
- else
- script.Parent.Text = bullets.Value.."/35"
- end
- end)
- end))
- TextLabel8.Name = "Headshot"
- TextLabel8.Parent = ScreenGui5
- TextLabel8.Transparency = 1
- TextLabel8.Size = UDim2.new(0, 600, 0, 50)
- TextLabel8.Text = ""
- TextLabel8.Position = UDim2.new(1.5, 0, 0.5, -25)
- TextLabel8.BackgroundColor3 = Color3.new(1, 0.933333, 0)
- TextLabel8.BackgroundTransparency = 1
- TextLabel8.Font = Enum.Font.SciFi
- TextLabel8.FontSize = Enum.FontSize.Size60
- TextLabel8.TextColor3 = Color3.new(1, 0.933333, 0)
- TextLabel8.TextScaled = true
- TextLabel8.TextWrapped = true
- LocalScript9.Parent = Tool0
- table.insert(cors,sandbox(LocalScript9,function()
- local tool = script.Parent -- Getting the tool
- local plr = game.Players.LocalPlayer
- local player = game:GetService("Players").LocalPlayer -- Getting the player
- local mouse = player:GetMouse() -- Getting the mouse
- local sound = tool:WaitForChild("Gunfire")
- local torso = "" -- Nothing for now.
- local reloading = false -- Variable to check if we are currently reloading
- local contextActionService = game:GetService("ContextActionService") -- Allow us to cater for Mobile players
- local bodytype = nil -- Nil for now but will check whether player is R6 or R15
- local difference = 0 -- Difference between position of head and mouse
- local replicatedstorage = game:GetService("ReplicatedStorage")
- local gungui = tool:WaitForChild("GunGUI")
- local bullets = tool:WaitForChild("Bullets")
- local reloadtime = 3
- -- Remote Events
- local equipAnimation = replicatedstorage:WaitForChild("EquipAnimation")
- local headshot = replicatedstorage:WaitForChild("Headshot")
- local reload2 = replicatedstorage:WaitForChild("Reload")
- local shootevent = replicatedstorage:WaitForChild("ShootEvent")
- local unequipanimation = replicatedstorage:WaitForChild("UnequipAnimation")
- local gunshot = script.Parent.gunshot
- -- Remote Functions
- local checkBodyType = replicatedstorage:WaitForChild("CheckBodyType")
- local fetchBulletsLeft = replicatedstorage:WaitForChild("FetchBulletsLeft")
- -- Find Body Type
- function findBodyType() -- Used to determine whether a player is R6 or R15
- bodytype = checkBodyType:InvokeServer(tool) -- Invoking the Remotefunction to do a check on the server
- print(bodytype)
- end
- -- Reloading function
- function reload()
- reloading = true
- reload2:FireServer(tool.reload)
- mouse.Icon = "http://www.roblox.com/asset?id="
- player.PlayerGui:WaitForChild("GunGUI").Bullets.Text = "Reloading..."
- wait(reloadtime)
- bullets.Value = 35
- player.PlayerGui:WaitForChild("GunGUI").Bullets.Text = bullets.Value.."/35"
- mouse.Icon = "http://www.roblox.com/asset?id="
- equipAnimation:FireServer(tool.shoot)
- reloading = false
- end
- -- When the tool is equipped, the following event will run
- tool.Equipped:Connect(function(mouse)
- gungui:Clone().Parent = player.PlayerGui -- We are cloning the Gun GUI into the player's PlayerGUI
- findBodyType() -- Calling the function above to check the body type.
- equipAnimation:FireServer(tool.shoot) -- Calling the equip animation remoteevent so that the server can play the animation
- mouse.Icon = "http://www.roblox.com/asset?id="
- mouse.Button1Down:Connect(function()
- if bullets.Value <=0 or reloading == true then
- -- Don't do anything
- else
- local head = game.Workspace[player.Name].Head.CFrame.lookVector
- local mouse = CFrame.new(game.Workspace[player.Name].Head.Position,mouse.Hit.p).lookVector
- difference = (head-mouse)
- local ray = Ray.new(tool.Handle.CFrame.p,(player:GetMouse().Hit.p - tool.Handle.CFrame.p).unit*300)
- local part,position = game.Workspace:FindPartOnRay(ray,player.Character,false,true)
- local shot = game.Workspace[player.Name].Humanoid:LoadAnimation(gunshot)
- shot:Play()
- sound:Play()
- if difference.magnitude < 1.33 then
- shootevent:FireServer(tool,position,part)
- bullets.Value = bullets.Value - 1
- end
- end
- end)
- local reloadMobileButton = contextActionService:BindAction("ReloadBtn",reload,true,"r")
- contextActionService:SetPosition("ReloadBtn",UDim2.new(0.72,-25,0.20,-25))
- contextActionService:SetImage("ReloadBtn","http://www.roblox.com/asset/?id=")
- end)
- tool.Unequipped:Connect(function()
- mouse.Icon = ""
- unequipanimation:FireServer(tool.shoot)
- player.PlayerGui.GunGUI:Destroy()
- contextActionService:UnbindAction("ReloadBtn")
- end)
- headshot.OnClientEvent:Connect(function()
- player.PlayerGui.GunGUI.Headshot:TweenPosition(UDim2.new(0.5,-100,0.5,-25), "Out","Quint",0.3)
- wait(1.5)
- player.PlayerGui.GunGUI.Headshot:TweenPosition(UDim2.new(-1,0,0.5,-25), "In","Quint",0.4)
- wait(0.5)
- player.PlayerGui.GunGUI.Headshot.Position = UDim2.new(1.5,0,0.5,-25)
- end)
- end))
- Animation10.Name = "gunshot"
- Animation10.Parent = Tool0
- Animation10.AnimationId = "rbxassetid://1133099894"
- Part11.Name = "Handle"
- Part11.Parent = Tool0
- Part11.Reflectance = 1
- Part11.Transparency = 1
- Part11.Size = Vector3.new(0.110000007, 0.179999933, 0.190000519)
- Part11.CFrame = CFrame.new(3.1850009, 1.00000429, -13.1549959, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Part11.RightSurface = Enum.SurfaceType.Studs
- Part11.Position = Vector3.new(3.1850009, 1.00000429, -13.1549959)
- Script12.Name = "Weld"
- Script12.Parent = Tool0
- table.insert(cors,sandbox(Script12,function()
- local prev
- local parts = script.Parent:GetChildren()
- for i = 1,#parts do
- if ((parts[i].className == "Part") or (parts[i].className == "Handle") or (parts[i].className == "WedgePart") or (parts[i].className == "Seat") or (parts[i].className == "TrussPart") or (parts[i].className == "VehicleSeat") or (parts[i].className == "UnionOperation") or (parts[i].className == "SkateboardPlatform")) then
- if (prev ~= nil) then
- local weld = Instance.new("Weld")
- weld.Part0 = prev
- weld.Part1 = parts[i]
- weld.C0 = prev.CFrame:inverse()
- weld.C1 = parts[i].CFrame:inverse()
- weld.Parent = prev
- parts[i].Anchored = false
- end
- prev = parts[i]
- end
- end
- wait(3)
- end))
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = game:GetService("Players").LocalPlayer.Backpack
- pcall(function() v:MakeJoints() end)
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement