How do i check if the ball is on the ground

hii
i want to check if the ball is on the ground, cause i want to make that when i press g on the tool, if the ball is on the ground then the skill wont ve used, if the ball is in air, the skill can be used.
how do i check that?

A solid workaround is putting a humanoid in the ball and checking the humanoid property FloorMaterial!

Use :GetTouchingParts on the ball to see if it is touching anything, if it is still in the air it will return nil, otherwise it will return an object.

sorry its the first time i hear that, so i need to do something like this?


Player.Character["Right Leg"].Touched:connect(function(hit)
	if hit.Name ~= "Ball" then return end
if hit:GetTouchingParts() then
--stuff for the skill

     end
end)

No you would check the ball itself

if not Ball:GetTouchingParts() then
--its in the air
end

but the hit is actually the ball, or not

I’m not 100% on this but basically Ball:GetTouchingParts() gets a list of objects the ball is touching. So what he’s doing with

if not Ball:GetTouchingParts() then
end

is checking if the list of touching objects is empty then to proceed with the code. I believe if you did Ball:GetTouchingPart(ObjectName) you could do print(ObjectName) and it would print the names of the objects the ball is touching. This could be useful for debugging. Hope this helps!

so if i understood i should do somethnig like this

Player.Character["Right Leg"].Touched:connet(function(hit)
if hit.Name ~= "Ball" then return end
if not game.Workspace:WaitForChild("Ball"):GetTouchingParts(ObjctName) then
--stuff for the skill
print(ObjectName)
       end
end)

right?

What do you mean by “ball on the ground”? Could you show use a video as reference or explain what the ball is?

What I mentioned before is if you want a sort of blacklist so that the ball touching a wall will not count. If it doesn’t matter what it touched, .Touched may also work. Check if what it touched was a BasePart and isn’t a player’s character, and that would have about the same result.

The below line will check if the ball is in the air.

if not game.Workspace:WaitForChild("Ball"):GetTouchingParts() ~= nil then
--skill here

This should work:

Player.Character["Right Leg"].Touched:connet(function(hit)
       if hit.Name ~= "Ball" then return end
       if not game.Workspace:WaitForChild("Ball"):GetTouchingParts() ~= nil then
              --stuff for the skill
              end
       end
end)

no, i can still hit it even if its on the ground

The code is interpreted wrong if you you would like to see if the ball is on the ground, you’d do this:

Player.Character["Right Leg"].Touched:connet(function(hit)
    if hit.Name ~= "Ball" then return end
    -- if hit is the ball then why not just do this instead?
    -- if not game.Workspace:WaitForChild("Ball"):GetTouchingParts() ~= nil then
    -- Previous comment is ineffective as what if there were multiple objects named "Ball".
    if not hit:GetTouchingParts() then
        --stuff for the skill
    end
end)
Player.Character["Right Leg"].Touched:connect(function(hit)
 if hit.Name ~= "Ball" then return end
 if not game.Workspace:WaitForChild("Ball"):GetTouchingParts() ~= nil then
 if not hit:GetTouchingParts() then
--stuff for the skill
              end
        end
end)

llike this? if yes then i tried and it doesnt get the hit, like the ball stand still

No, just copy my code and it will work (hopefully).

no it doesn’t work, if u want i can send a video of how i want it to work

Ahh ok, I’ve also tried it and doesn’t work. The implementation I did was to check if the GetTouchingParts() objects table was empty, if it was yours it’ll look something like this:

-- Let's just pretend that right leg was a variable
RightLeg.Touched:Connect(function(Hit)
    if Hit and Hit.Parent then
        -- Remove the or statement, if the part's name is the ball.
        if Hit.Name == "Ball" or Hit.Parent.Name == "Ball" then
            if #Hit:GetTouchingParts() > 0 then
                -- Ball has something touched.
            else
                -- Ball is in the air.
            end
        end
    end
end)

yes it works tysm for the help