How would you get the final position the players humanoidrootpart is in the air? This is my code:
local FinalPosition;
if character.Humanoid.FloorMaterial == Enum.Material.Air then
print("Final Position In Air:")
FinalPosition = character.HumanoidRootPart.Position
end
Do you mean when the player is falling or was in the air?
Like the apex position the player is in the air right before they start falling down.
So like when before the player fall it get the player’s position on the air?
for i, v in pairs(game.Players:GetPlayers()) do
if v.Character then
local human = v.Character.Humanoid
human.Changed:Connect(function(property)
if property == "FloorMaterial" and human.FloorMaterial == Enum.Material.Air then
print("Final position in air is: " .. v.Character.HumanoidRootPart.Position)
end
end)
end
end
By the way I am on mobile right now and so I can’t test this, so if there is an error please let me know
Pretty much chars 4444444444444444
I put it in a serverscript and it doesn’t do anything.
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local human = char.Humanoid
human.Changed:Connect(function(property)
if property == "FloorMaterial" and human.FloorMaterial == Enum.Material.Air then
print("Final position in air is: " .. char.HumanoidRootPart.Position)
end
end)
end)
–Try this
Ran the script it still doesn’t do anything.
Try to put print(“testing”) in the .CharacterAdded event as the first line, and see if it prints or not.
I debugged and the if statement doesn’t run everything else does
Try to remove the first condition, so make it just:
if human.FloorMaterial == Enum.Material.Air then
That works but how would you get the position of the player in the air?
Once the if statement goes through (which means the player is in the air) you can do char.HumanoidRootPart.Position, which returns the player’s position. (Who is in the air)
Final script:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local human = char.Humanoid
human.Changed:Connect(function(property)
if human.FloorMaterial == Enum.Material.Air then
print("Final position in air is: " .. char.HumanoidRootPart.Position)
end
end)
end)
If this works like you wanted it to, mark it as the solution. If not, let me know.
By the way, the reason it wasn’t working earlier is because once the player joins, the character takes a bit to load (it happens pretty fast but still slower than script execution) and so when the script executed, the if player.Character condition was not met, so the code didn’t listen for the property change event. It might also have been due to the first condition in the .Changed block of code.