Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Servizi necessari
- local UserInputService = game:GetService("UserInputService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Players = game:GetService("Players")
- -- Imposta i tasti per eseguire l'abilità
- local abilityKey = Enum.KeyCode.C -- Tasto per il tiro
- local dashKey = Enum.KeyCode.V -- Tasto per lo scatto
- -- Funzione che esegue il tiro
- local function executeShot(player)
- -- Trova il personaggio del giocatore
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- -- Verifica se il giocatore ha la palla tramite la variabile "HasBall" nel modello del giocatore
- local hasBall = character:FindFirstChild("Values") and character.Values:FindFirstChild("HasBall") and character.Values.HasBall.Value == true
- if not hasBall then
- return -- Se il giocatore non ha la palla, non fare nulla
- end
- -- Calcola la direzione in cui il giocatore sta guardando
- local lookDirection = character.HumanoidRootPart.CFrame.LookVector
- -- Esegui l'animazione di tiro
- local animation = Instance.new("Animation")
- animation.AnimationId = "rbxassetid://18723315763" -- ID dell'animazione
- local animTrack = humanoid:LoadAnimation(animation)
- animTrack:Play()
- -- Aspetta che l'animazione finisca prima di eseguire il tiro
- animTrack.Stopped:Wait()
- -- Esegui il comando per il tiro (Distanza 245, direzione di dove guarda il giocatore)
- local args = {
- [1] = 245, -- Distanza del tiro
- [4] = lookDirection * 0.5 -- Direzione in cui il giocatore sta guardando
- }
- ReplicatedStorage:WaitForChild("Packages"):WaitForChild("Knit"):WaitForChild("Services"):WaitForChild("BallService"):WaitForChild("RE"):WaitForChild("Shoot"):FireServer(unpack(args))
- end
- -- Funzione per eseguire lo scatto
- local function executeDash(player)
- -- Trova il personaggio del giocatore
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- -- Verifica se il giocatore ha la palla tramite la variabile "HasBall" nel modello del giocatore
- local hasBall = character:FindFirstChild("Values") and character.Values:FindFirstChild("HasBall") and character.Values.HasBall.Value == true
- if not hasBall then
- return -- Se il giocatore non ha la palla, non fare nulla
- end
- -- Calcola la direzione in cui il giocatore sta guardando
- local lookDirection = character.HumanoidRootPart.CFrame.LookVector
- -- Esegui lo scatto (imposta la velocità del corpo)
- humanoid:Move(Vector3.zero) -- Ferma il movimento prima di applicare la velocità
- character:WaitForChild("HumanoidRootPart").AssemblyLinearVelocity = (lookDirection + Vector3.new(0, 0.2, 0)) * 500 -- Scatto in avanti
- end
- -- Ascolta la pressione dei tasti "C" e "V" per eseguire le abilità
- UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
- if gameProcessedEvent then return end -- Ignora gli input già processati dal gioco
- local player = Players.LocalPlayer
- if input.KeyCode == abilityKey then
- -- Se premi "C", esegui il tiro solo se il giocatore ha la palla
- executeShot(player)
- elseif input.KeyCode == dashKey then
- -- Se premi "V", esegui lo scatto solo se il giocatore ha la palla
- executeDash(player)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment