i’m trying to make an animal crossing like game and I wanted to make a dust like effect when the player walks outside, I just don’t know how to check if the player is walking,
here is the code
btw I know that it will only work If the player is walking forward, still doesn’t work
local Char = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Effect = ReplicatedStorage:WaitForChild("DirtParticle")
local LeftEffect = Effect:Clone()
LeftEffect.Parent = Char.LeftFoot
local RightEffect = Effect:Clone()
RightEffect.Parent = Char.RightFoot
if Char.Humanoid.MoveDirection.X > 0 or Char.Humanoid.MoveDirection.z > 0 then
LeftEffect.Enabled = true
RightEffect.Enabled = true
else
LeftEffect.Enabled = false
RightEffect.Enabled = false
end
You can use a very simple Running event, like this:
Char.Humanoid.Running:Connect(function(speed) -- Running function
if speed > 0 then -- Checks the speed
LeftEffect.Enabled = true
RightEffect.Enabled = true
else
if speed <= 0 then
LeftEffect.Enabled = false
RightEffect.Enabled = false
end
end
end)
This basically runs an event when the player is moving, and checks to see if their speed is over or under 0.
I wanted to know how to check if the player is moving so that when they are, the effect will be be active, if they are not, the effect will not be active
the only thing I had to change was that you checked if the speed was less or more than zero, it needed to check if the speed was 0 or less instead otherwise it always stayed on
local Char = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Effect = ReplicatedStorage:WaitForChild("DirtParticle")
local LeftEffect = Effect:Clone()
LeftEffect.Parent = Char.LeftFoot
local RightEffect = Effect:Clone()
RightEffect.Parent = Char.RightFoot
Char.Humanoid.Running:Connect(function(speed) -- Running function
if speed > 0 then -- Checks the speed
LeftEffect.Enabled = true
RightEffect.Enabled = true
else
if speed <= 0 then
LeftEffect.Enabled = false
RightEffect.Enabled = false
end
end
end)
add a particle in replicated storage and rename it to DirtParticle I am also trying to make a animal corssing game and it worked for me