So I need to update something everytime a player moves, simple, I thought, I’d just connect a event to Changed for the humanoidrootpart and update it if position is updated. But the position value isn’t modified when they walk around, so I tried something for the humanoid, ah I’ll use the MoveDirection thingy, well oop. That uh, only updates when they change their direction they’re walking in.
I’m completely lost, what do I use for detecting their movement?
Sorry I forgot it’s name, I mean’t movedirection.
You can use Humanoid.Running or you can use
Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if Humanoid.MoveDirection.Magnitude > 0 then
--Walking...
end
end)
None of these will work sadly, I need something that fires when the players position has changed, This is for a rendering esque thing, where I need to only send stuff to the client when they’re close to them. So I need to update that whenever the player moves.
If you wanna check if the position has changed, you can also just use Character.HumanoidRootPart:GetPropertyChangedSignal(“Position”)
that doesn’t fire when they’re moving around, just tested it.
You could try using this little code I put together. So per stepped, it’s going to check if the HRP CFrame has changed. If it has changed, it will run the function. You can also change this to Position, if you prefer.
local Character = script.Parent
local LastCF = Character.HumanoidRootPart.CFrame
local RS = game:GetService("RunService")
function Changed(NewCF)
print(NewCF)
end
RS.Stepped:Connect(function(dt)
local NewCF = Character.HumanoidRootPart.CFrame
if NewCF ~= LastCF then
LastCF = NewCF
Changed(NewCF)
end
end)
Yeah I’ll just setup something like this. Was hoping I could build it off of events instead of using the equal of a loop.
--|| FederalTactical
local RunService = game:GetService("RunService")
local Character = script.Parent
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local lastPos = HumanoidRootPart.Position
RunService.Stepped:Connect(function()
if HumanoidRootPart.Position ~= lastPos then
print("Player moved!")
lastPos = HumanoidRootPart.Position
end
end)
RunService: RunService | Roblox Creator Documentation
Character: Player | Roblox Creator Documentation
Vector3: Vector3 | Roblox Creator Documentation
- Script Location: StarterPlayer → StarterCharacterScripts
I just noticed that someone else posted the same thing, have a nice day.