Hello! So basically I have this script I made so that when you have the ball and you tap e, you would shoot the ball and it would play a jumpshot animation. I’m having trouble figuring out whats wrong with my code. Can you please help me?
Client:
local player = game.Players.LocalPlayer local character = player.Character local rep = game:GetService("ReplicatedStorage") local uis = game:GetService("UserInputService") local jumpshot = rep.Animations:WaitForChild("jumpshot animation") local jumpshotanimation = character.Humanoid:LoadAnimation(jumpshot) local shoot = rep.Events:WaitForChild("shoot") local Basketball = game.Workspace.Basketball local ShotBall = false local Debounce = true uis.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E and not Debounce and not ShotBall and character.Humanoid:FindFirstChild(Basketball) then ShotBall = true Debounce = false jumpshotanimation:Play() wait() Debounce = true ShotBall = false shoot:FireServer() end end)
Server:
local rep = game:GetService("ReplicatedStorage") local shoot = rep.Events:WaitForChild("shoot") local GoalPart = game.Workspace.Hoop.GoalPart local Basketball = game.Workspace.Basketball local ShotBall = false shoot.OnServerEvent:Connect(function(player) local mag = (GoalPart.Position - player.Character.HumanoidRootPart.Position).Magnitude local unit = (GoalPart.Position - player.Character.HumanoidRootPart.Position).Unit if ShotBall == false then Basketball.Velocity = (unit * mag) + Vector3.new(0, 70, 0) Basketball.Ball.Part0 = nil Basketball.Parent = workspace ShotBall = true end ShotBall = false end)
I would really appreciate your help. Thank you and remember to stay safe.