this is a client sided script located in the workspace, normally it should transform the player’s walkspeed to 10 when he walks on sand but it doesn’t
script:
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:FindFirstChildOfClass("Humanoid")
hum.PlatformStanding:Connect(function(active)
if active then
if Enum.Material.Sand and Enum.HumanoidStateType.Running then
hum.WalkSpeed = 10
else
hum.WalkSpeed = 16
end
end
end)
You can check what material the character is standing on with Humanoid.FloorMaterial.
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:FindFirstChildOfClass("Humanoid")
hum.PlatformStanding:Connect(function(active)
if active then
if hum.FloorMaterial == Enum.Material.Sand and Enum.HumanoidStateType.Running then
hum.WalkSpeed = 10
else
hum.WalkSpeed = 16
end
end
end)
Sorry, I just checked, and the floor material is always set to Air when platform standing.
If you want the player’s speed to decrease when walking on sand, you can detect whenever the player tries to move, then check if they are on sand.
Try this:
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:FindFirstChildOfClass("Humanoid")
hum:GetPropertyChangedSignal("MoveDirection"):Connect(function() -- Fires when the player tries to walk
if hum.FloorMaterial == Enum.Material.Sand then -- Check if the player is standing on sand
hum.WalkSpeed = 10
else
hum.WalkSpeed = 16
end
end)