#How would I check if the player is moving?
69 messages · Page 1 of 1 (latest)
No don't do that there's another method
Hold on let me find it
Hey, there’s a few ways you can do this, I personally would use “MoveDirection” to check if the player is moving or not, I’ve attached a link that can give you more information on “MoveDirection” if you’re interested. If you would like to test my example, I just put a local script in “StarterPlayerScripts”. Local Script: local Player = game.P...
Look at this
thanks
The Humanoid has a property called MoveDirection which determines, as a unit vector, the direction a player is moving in. You can access the Magnitude property and see if it’s greater than 0 to know if there is active movement without relying on what their HumanoidStateType is.
no
that's a single for loop
a game has normally dozens of for loops that iterate over hundreds of entities
you can make it event based though if that worries you 🤷♂️
is just a bit harder
movedirection?
i'll try it and see if it works
ok?
are you doing this for the walk animation?
because if you are there is a much simpler way of doing this
WOAH!!!
dont disrespect lua like that
just make states
|:
lemme just make it and i'll show you
local players = game:GetService("Players")
local runservice = game:GetService("RunService")
local plr = players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
runservice.RenderStepped:Connect(function()
local hum = char:FindFirstChild("Humanoid")
if hum then
local dir = hum.MoveDirection.Magnitude
if dir > 0 then
plr.State.Value = "Moving"
else
plr.State.Value = "Idle"
end
end
print(plr.State.Value)
end)
this is what i did
i also made a string value inside the player when they join
it works
whenever im still it prints idle and whenever i move it prints moving
what?
pathetic
last time i went to sleep was 2 days ago at 11:30pm
** You are now Level 4! **
because i like helping ppl on dev forum
no they aren't xd
i started 2 months ago and i'm already an extremely good coder
that is true
but i dont want to do this my entire life xd
direction
doesn't really matter
for free
i would die of poorness
ooooooooooooooh
i would be able to buy a happy meal with that kind of money
you're smart
an adult happy meal lmao
no i would not
i can beat on of those in a fight
they are very steppable
AMONGUS
AMOGUS
on a real note though does everything work?
is your char called safeRemain
i was just checking
you have to do character:WaitForChild("Humanoid")
or you could ```lua
local hum = character:FindFirstChild("Humanoid")
if hum then
-- code
end
what does the second argument in :WaitForChild
always wondered that
i also know that
its a number of seconds when it should give up waiting
have you actually made the state string value yet
(server script)
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(plr)
local state = Instance.new("StringValue", plr) state.Name = "State"
end)
you aren't stupid
just make a new script and put this in
ok