Advertisement
RandomMagics

RoBowling Script

Jun 6th, 2022
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. local plr = game.Players.LocalPlayer
  2. local uis = game:GetService("UserInputService")
  3.  
  4. local remote = game:GetService("ReplicatedStorage").ServerRemote
  5.  
  6. function getPinPos()
  7. for i,v in pairs(workspace.FunctionalAssets.BowlingLanes:GetDescendants()) do
  8. if v:IsA("StringValue") and v.Value == plr.Name then
  9. return v.Parent.PinPositions.Pin1.Position
  10. else
  11. local dist, pos = 9e9
  12. for i,v in pairs(workspace.FunctionalAssets.BowlingLanes:GetDescendants()) do
  13. if v.Name ~= "PinController" and string.find(v.Name:lower(), "pin") and v:IsA("BasePart") then
  14. print(v.Name)
  15. local mag = (plr.Character.Head.Position - v.Position).Magnitude
  16. if dist > mag then
  17. dist = mag
  18. pos = v.Position
  19. end
  20. end
  21. end
  22. return pos
  23. end
  24. end
  25. end
  26.  
  27. function throwBall()
  28. if plr.Character:FindFirstChild("BowlingBallPractise") then
  29. local ball = plr.Character:FindFirstChild("BowlingBallPractise")
  30. local pos = getPinPos()
  31.  
  32. if pos and ball then
  33. local arguments = {
  34. [1] = "ThrowBall",
  35. [2] = {
  36. ["Velocity"] = 150,
  37. ["MouseData"] = {
  38. ["Position"] = pos
  39. }
  40. }
  41. }
  42. ball.HitBox.CanCollide = false
  43. ball.HitBox.Size = Vector3.new(10, 10, 10)
  44. remote:InvokeServer(unpack(arguments))
  45. end
  46. elseif plr.Character:FindFirstChild("BowlingBall") then
  47. local ball = plr.Character:FindFirstChild("BowlingBall")
  48. local pos = getPinPos()
  49.  
  50. if pos and ball then
  51. local arguments = {
  52. [1] = "ThrowBall",
  53. [2] = {
  54. ["Velocity"] = 150,
  55. ["MouseData"] = {
  56. ["Position"] = pos
  57. }
  58. }
  59. }
  60. ball.HitBox.CanCollide = false
  61. ball.HitBox.Size = Vector3.new(6, 6, 6)
  62. remote:InvokeServer(unpack(arguments))
  63. end
  64. end
  65. end
  66.  
  67. function keyPress(key, gpe)
  68. if not gpe and key.KeyCode == Enum.KeyCode.X then
  69. throwBall()
  70. end
  71. end
  72.  
  73. uis.InputBegan:Connect(keyPress)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement