Character Speed on Different Terrain

How can I make a player’s speed slower when the player walks on different type of terrain (Snow, Rock, Mud, etc.)

3 Likes

The humanoid has a property called ‘FloorMaterial’, you can check for when that changes and adjust the speed accordingly.

5 Likes

Either as k_reex said,
Or set up a region3 if the area is square/rectangle

2 Likes

How can I check for when it changes?

Use the Property changed value for a function

I am a bit new to scripting. Can you tell me how?

I think the function @topcst is referring to is the :GetPropertyChangedSignal() function of instances in Roblox.

In this case you can check for when the FloorMaterial property of the Humanoid is changed, like so:

local humanoid -- define the humanoid here

humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
    -- the argument we pass is a string with the name of the property

    print(humanoid.FloorMaterial) --> whatever material the player is standing on; outputs every time that changes.
end)
4 Likes