How to add particle emitter to player's feet, and check if player is stationary

Hello today i want to make it so when the player walks on sand or some other material a particle emitter activates and deactivates when stepped on grass for example. I think to spawn it i might i have to use instance.new but idk. I know how to do most of this i think here is what i have so far, the script will be in startercharacterscripts.

wait(5)
local chara = script.Parent:FindFirstChild("Humanoid")

script.Parent.LeftFoot.ParticlePart.Enabled = false

script.Parent.RightFoot.ParticlePart.Enabled = false

--Creating of the Parts and ParticleEmitter here i think

if chara.FloorMaterial == Enum.Material.Sand then

script.Parent.LeftFoot.ParticlePart.Enabled = true

script.Parent.RightFoot.ParticlePart.Enabled = true


elseif chara.FloorMaterial == Enum.Material.Grass then

script.Parent.LeftFoot.ParticlePart.Enabled = false

script.Parent.RightFoot.ParticlePart.Enabled = false

end

i have no idea where the check if player is stationary part goes

1 Like

In order to check if the player is not stationary, you could try using HumanoidRootPart.Velocity.magnitude, and check if that is greater than a specific number.

Also instead of waiting every 5 seconds, you could use

Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
  --rest of script goes here...
end)
1 Like

There are multiple ways to check if a player is stationary. The most common way is to check the WalkToPoint of the players humanoid.

For example:

if humanoid.WalkToPoint == Vector3.new(0,0,0) then
--stationary
else
--moving
end
2 Likes