Hello,
So I’m currently working on a system which requires the script to scan the workspace for the ball to be able to play the animation. I’ve ran into a problem where it only works if the item’s parent is workspace and not a character. Please help.
Code:
if not Character:FindFirstChild('Football') then
CanUse = false
-- Find Ball --
if Ball then
local CheckDistance = (Torso.Position - Ball.Position).Magnitude
if Distance == nil then
Football = Ball
Distance = CheckDistance
else
if CheckDistance < Distance then
Football = Ball
Distance = CheckDistance
end
end
end
– Function –
local function findBall()
if workspace:FindFirstChild("Football") then
return workspace:FindFirstChild("Football")
end
for _, player in pairs(game.Players:GetPlayers()) do
if not player.Character then
continue
end
local ball = player.Character:FindFirstChild("Football")
if ball and ball:IsA("MeshPart") then
return ball
end
end
end