The question title is pretty self-explanatory. Basically what I want to do is have the characters not be able to control their movement while their freefalling or in mid-air, to make stuff more realistic. But I'm not really sure how I would go about doing something like that, any suggestions?
NOTE: I'm not asking for a script, I'm asking for suggestions or methods or a breakdown.
Thanks.
What is important here: If you take a look at the events of a humanoid, you'll notice that there is a freeFalling
event.
The key to understanding the freeFalling
event is that the argument which is given by the event is the status of whether or not the player is actually freeFalling anymore. For example, let's make a local script to test this event out:
local plr = game.Players.LocalPlayer local chr = plr.Character or plr.CharacterAdded:wait() local hum = chr:FindFirstChild("Humanoid") local falling = false hum.FreeFalling:connect(function(isFalling) falling = isFalling if isFalling then while falling do print("Falling!") wait() end else print("Not Falling!") end end)
Now, if you want to make the character still, we obviously only have to put the humanoid WalkSpeed property to 0, which makes the player still, and if the character is not falling, then we just set the walkspeed back to normal.
local plr = game.Players.LocalPlayer local chr = plr.Character or plr.CharacterAdded:wait() local hum = chr:FindFirstChild("Humanoid") local falling = false hum.FreeFalling:connect(function(isFalling) falling = isFalling if isFalling then while falling do hum.WalkSpeed = 0; wait() end else hum.WalkSpeed = 16; end end)
Humanoid: http://wiki.roblox.com/index.php?title=API:Class/Humanoid
FreeFalling: http://wiki.roblox.com/index.php?title=API:Class/Humanoid/FreeFalling
I had a solution!, Put a script inside startercharacterscripts then put this isnide the script
local bg = script:WaitForChild("BodyVelocity") while true do wait() if script.Parent.Humanoid.FloorMaterial == Enum.Material.Air then local vel = script.Parent.Humanoid.WalkSpeed bg.Velocity = Vector3.new((script.Parent.Humanoid.MoveDirection.X * (vel + 2)) ,0,(script.Parent.Humanoid.MoveDirection.Z * (vel + 2))) bg.MaxForce = Vector3.new(script.Parent.Humanoid.WalkSpeed + 100000 , 0 , script.Parent.Humanoid.WalkSpeed + 100000) script.Parent.Humanoid.WalkSpeed = 0 bg.Parent = script.Parent.Torso repeat wait() until script.Parent.Humanoid.FloorMaterial ~= Enum.Material.Air script.Parent.Humanoid.WalkSpeed = vel bg.Parent = script end end
and then, Put a body velocity parented with the script and done! It worked for me! (R6 only, Change all torso for humanoidrootpart if it is r15 or a custom rig!)
I'd recommend changing the walk speed properties or changing the controller service to "NIL".