So I have a shovel tool and I only want it to activate if the player is touching the ground (not jumping, falling, etc.). Is there some code that Roblox has for identifying if the player is on the ground or is there some way I could make a script for this. Im not familiar with any commands that would make this work. Please help if you can.
Humanoid.FloorMaterial
http://wiki.roblox.com/index.php?title=API:Class/Humanoid/FloorMaterial
Description : This property contains the Material of the part or terrain cell that the Humanoid is currently standing on (as calculated in the last Humanoid step). If the Humanoid is not currently standing on any part the value of the property would be Material of Air.
try this:
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local hum = character.Humanoid local rs = game:GetService("RunService") rs.RenderStepped:Connect(function() if hum.FloorMaterial ~= nil then print('Standing on '..hum.FloorMaterial.Name) else print('Not standing on the floor') end end)
Sorry about the late reply, but after much testing I got chexyalani’s system to work for my purposes. Btw the other answers are bad, but chexyalani’s answer is definitely the way to go for anyone who is looking for a solution. You can easily modify it to run when you need it to. Thx chexyalani.
This will check how far away a player is from the floor you can mess with the numbers and names to what you wish.
((game.Floor.Position+Vector3.new(0,1,0)) Character.HumanoidRootPart.Position).magnitude <=1