iOSdeveloper

Untitled

Jan 26th, 2025
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. -- Servizi necessari
  2. local UserInputService = game:GetService("UserInputService")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4. local Players = game:GetService("Players")
  5.  
  6. -- Imposta i tasti per eseguire l'abilità
  7. local abilityKey = Enum.KeyCode.C -- Tasto per il tiro
  8. local dashKey = Enum.KeyCode.V -- Tasto per lo scatto
  9.  
  10. -- Funzione che esegue il tiro
  11. local function executeShot(player)
  12. -- Trova il personaggio del giocatore
  13. local character = player.Character or player.CharacterAdded:Wait()
  14. local humanoid = character:WaitForChild("Humanoid")
  15.  
  16. -- Verifica se il giocatore ha la palla tramite la variabile "HasBall" nel modello del giocatore
  17. local hasBall = character:FindFirstChild("Values") and character.Values:FindFirstChild("HasBall") and character.Values.HasBall.Value == true
  18.  
  19. if not hasBall then
  20. return -- Se il giocatore non ha la palla, non fare nulla
  21. end
  22.  
  23. -- Calcola la direzione in cui il giocatore sta guardando
  24. local lookDirection = character.HumanoidRootPart.CFrame.LookVector
  25.  
  26. -- Esegui l'animazione di tiro
  27. local animation = Instance.new("Animation")
  28. animation.AnimationId = "rbxassetid://18723315763" -- ID dell'animazione
  29. local animTrack = humanoid:LoadAnimation(animation)
  30. animTrack:Play()
  31.  
  32. -- Aspetta che l'animazione finisca prima di eseguire il tiro
  33. animTrack.Stopped:Wait()
  34.  
  35. -- Esegui il comando per il tiro (Distanza 245, direzione di dove guarda il giocatore)
  36. local args = {
  37. [1] = 245, -- Distanza del tiro
  38. [4] = lookDirection * 0.5 -- Direzione in cui il giocatore sta guardando
  39. }
  40.  
  41. ReplicatedStorage:WaitForChild("Packages"):WaitForChild("Knit"):WaitForChild("Services"):WaitForChild("BallService"):WaitForChild("RE"):WaitForChild("Shoot"):FireServer(unpack(args))
  42. end
  43.  
  44. -- Funzione per eseguire lo scatto
  45. local function executeDash(player)
  46. -- Trova il personaggio del giocatore
  47. local character = player.Character or player.CharacterAdded:Wait()
  48. local humanoid = character:WaitForChild("Humanoid")
  49.  
  50. -- Verifica se il giocatore ha la palla tramite la variabile "HasBall" nel modello del giocatore
  51. local hasBall = character:FindFirstChild("Values") and character.Values:FindFirstChild("HasBall") and character.Values.HasBall.Value == true
  52.  
  53. if not hasBall then
  54. return -- Se il giocatore non ha la palla, non fare nulla
  55. end
  56.  
  57. -- Calcola la direzione in cui il giocatore sta guardando
  58. local lookDirection = character.HumanoidRootPart.CFrame.LookVector
  59.  
  60. -- Esegui lo scatto (imposta la velocità del corpo)
  61. humanoid:Move(Vector3.zero) -- Ferma il movimento prima di applicare la velocità
  62. character:WaitForChild("HumanoidRootPart").AssemblyLinearVelocity = (lookDirection + Vector3.new(0, 0.2, 0)) * 500 -- Scatto in avanti
  63. end
  64.  
  65. -- Ascolta la pressione dei tasti "C" e "V" per eseguire le abilità
  66. UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
  67. if gameProcessedEvent then return end -- Ignora gli input già processati dal gioco
  68.  
  69. local player = Players.LocalPlayer
  70.  
  71. if input.KeyCode == abilityKey then
  72. -- Se premi "C", esegui il tiro solo se il giocatore ha la palla
  73. executeShot(player)
  74. elseif input.KeyCode == dashKey then
  75. -- Se premi "V", esegui lo scatto solo se il giocatore ha la palla
  76. executeDash(player)
  77. end
  78. end)
Add Comment
Please, Sign In to add comment