Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tool = script.Parent --get tool--
- local player = game:GetService("Players").LocalPlayer--get player--
- local mouse = player:GetMouse()--get mouse--
- local sound = tool:WaitForChild("Gunfire")
- local torso = "" -- noting--
- local reloading = false -- var check reloading ok--
- local contextActionService = game:GetService("ContextActionService") -- work for mobile bruh --
- local bodytype = nil --nil ok n ow but chekclaterifplayerisr15--
- local difference = 0 -- difference in head and mouse--
- local replicatedstorage = game:GetService("ReplicatedStorage")
- local bullets = tool:WaitForChild("Bullets")
- local reloadtime = 3
- --remote event--
- 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 FUNCION!!!!!--
- local checkBodyType = replicatedstorage:WaitForChild("CheckBodyType")
- local fetchBulletsLeft = replicatedstorage:WaitForChild("FetchBulletsLeft")
- --Find body--
- function findBodyType() -- DETERMIN R15--
- bodytype = checkBodyType:InvokeServer(tool) -- invoke remote function to check on servefrafdsafa--
- print(bodytype)
- end
- --RELOAD FUNCTION--
- function reload()
- reloading = true
- reload:FireServer(tool.reload)
- wait(reloadtime)
- bullets.Value = 6
- equipAnimation:FireServer(tool.shoot)
- reloading = false
- end
- --WHEN TOOL ON EVEN WILL RUN--
- tool.Equipped:Connect(function(mouse)
- findBodyType() -- call function "heyyyyyyyyy i need to check body type."
- equipAnimation:FireServer(tool.shoot) -- calling equip animation so seerver play "YO PLAYPLAYPLAY"
- mouse.Button1Down:Connect(function()
- if bullets.Value <=0 or reloading == true then
- -- DON'T DO ANYTING --
- 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)
- soundTonguelay()
- 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=10952420")
- end)
- tool.Unequipped:Connect(function()
- unequipanimation:FireServer(tool.shoot)
- contextActionService:UnbindAction("ReloadBtn")
- end)
- headshot.OnClientEvent:Connect(function()
- end)
Advertisement
Add Comment
Please, Sign In to add comment