What im trying to do is making the basketball shoot or in other terms making the part go to where the person is looking at when he clicks down. Keep in mind the basketball is a part and not a tool.
local function Shoot_Event()
local ball = Character:WaitForChild("Ball")
if ball then
local Hit = Mouse.Hit.p
local ShootingPosition = Character.PrimaryPart.Position
local HeadLook = (Hit - Character.Head.Position).unit
local SpawnPosition = ShootingPosition + HeadLook * 5
local Power = ball.Power.Value
print("work")
ShootingEvent:FireServer(Hit, SpawnPosition, Power)
end
end
this local script works fine
local function Server_Shoot(Player, Hit, SpawnPos, Power)
local Character = Player.Character or game.Workspace:FindFirstChild(Player.Name)
local ball = Character:FindFirstChild("Ball")
ball.Parent = game.Workspace
ball.Position = SpawnPos
ball.LastPlayer.Value = Player
ball.Velocity = (Player.Character.Head.Position - Hit).unit * - Power + Vector3.new(0,50,0)
end
But however this server script doesn't for some reason it says "attempt to index local "ball" (a nil value)

6 comments
Is ball being used in just that function?
where was the ball made?
The ball is being used in different functions. The ball is a part and not a tool but the error is on 4th line
in the first script u need to do local ball = Character:FindFirstChild("ball") because wait is used on something thats always inside from the start of spawn
so do not use WaitForChild because one example is WaitForChild can be used on Humanoid or HumanoidRootPart etc
I did i used FindFirstChild() but then it didn't work either i printed the ball's parent and it was the characters model