Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --var
- local tool = script.Parent
- local player = game:GetService("Players").LocalPlayer
- local mouse = player:GetMouse()
- local sound = tool:WaitForChild("GunFire")
- local torso = ""
- local reloading = false
- local contextActionService = game:GetService("ContextActionService")
- local bodytype = nil
- local diffrence = 0
- local replicatedstorage = game:GetService("ReplicatedStorage")
- local gungui = tool:WaitForChild("GunGUI")
- local bullets = tool:WaitForChild("Bullets")
- --remote events
- local equipAnimation = replicatedstorage:WaitForChild("EquipAnimation")
- local headshot = replicatedstorage:WaitForChild("Headshot")
- local reload = replicatedstorage:WaitForChild("Reload")
- local shootevent = replicatedstorage:WaitForChild("ShootEvent")
- local unequipanimation = replicatedstorage:WaitForChild("UnequipAnimation")
- -- remote function
- local checkBodyType = replicatedstorage:WaitForChild("CheckBodyType")
- local fetchBulletsLeft = replicatedstorage:WaitForChild("FetchBulletsLeft")
- --var
- --------------------------------------------------------
- function findBodyType()
- bodytype = checkBodyType:InvokeServer(tool)
- print(bodytype)
- end
- function reload()
- reloading = true
- reload:FireServer(tool.reload)
- mouse.Icon = "https://www.roblox.com/library/936489170/reloading"
- player.PlayerGui:WaitForChild("GunGUI").Bullets.Text = "Reloading!"
- end
- tool.Equipped:Connect(function(mouse)
- gungui:Clone().Parent = player.PlayerGui
- findBodyType()
- equipAnimation:FireServer(tool.shoot)
- mouse.Button1Down:Connect(function()
- if bullets.Value <=0 or reloading == true then
- else
- local head = game.Workspace[player.Name].Head.CFrame.lookVector
- local mouse = CFrame.new(game.Workspace[player.Name].Head.Position,mouse.hit.p).lookVector
- diffrence = (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)
- sound:Play()
- if diffrence.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,.20,-25))
- contextActionService:SetImage("ReloadBtn","https://www.roblox.com/library/10952420/Letter-R")
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement