How to know if the position of a play changed

all the position properties of the character do not change for example the torso position does not change even after moving sorry for asking such a goofy question i haven’t been on studio for a year basically

basically what property changes when the player moves?

Position changes, but how are you trying to get that?
Are you searching the local player in the Workspace, or the Player in the Players service folder?
Whenever asking for scripting support please post your script so we can see what how you are trying to do it.

1 Like

If I remember, The Players MoveDirection Changes when they Move, And I think thats a Property of the Humanoid, but there may be a Event to determine if they are running or not, like with Humanoid.StateChanged (if thats the right name) where you can check if they have a specific HumanoidStateType.

1 Like

im doing it from a local script

local Character = game.Players.LocalPlayer.CharacterAdded:Wait()
local camera = workspace.CurrentCamera
local PartCam = workspace.Cam

camera.CameraType = Enum.CameraType.Fixed
camera.CFrame = PartCam.CFrame

task.wait(0.001)
print(Character.Name)
Character.Head.Changed:connect(function(Property)
	print(Property)
	if Property == "Position" then
		print("e")
		PartCam.CFrame = CFrame.lookAt(PartCam.CFrame.Position, Character.Head.CFrame.Position)
		PartCam.Rotation = Vector3.new(0,0,PartCam.Rotation.Z)
	end
end)

literally nothing works except the prints

You cant “detect” position changes like that, you’d have to do a loop or connect to the Humanoid.Running, but the loop is probably better

So you arent constantly changing the position/cframe of the Camera you could detect if it was changed like so

local runService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local partCam = workspace:WaitForChild("Cam")

local loopConnection = nil
local savedPos = nil

local function updateCamera(character)
	print("Updating camera")
	
	partCam.CFrame = CFrame.lookAt(
		partCam.CFrame.Position, 
		character.Head.CFrame.Position,
	)
	partCam.Rotation = Vector3.new(0, 0, partCam.Rotation.Z)
end

player.CharacterAdded:Connect(function(character)
	if loopConnection ~= nil then
		loopConnection:Disconnect()
	end
	
	loopConnection = runService.RenderStepped:Connect(function()
		if not savedPos or character.PrimaryPart.Position ~= savedPos then
			savedPos = character.PrimaryPart.Position
			updateCamera(character)
		end
		
		if not character.Parent then
			loopConnection:Disconnect()
		end
	end)
end)
1 Like

I would try something with what @DasKairo mentioned. I would use the Magnitude of MoveDirection of the player’s humanoid.

local Players = game:GetService("Players")

local player  = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

character:WaitForChild("Humanoid"):GetPropertyChangedSignal("MoveDirection"):Connect(function()
    if character.Humanoid.MoveDirection.Magnitude > 0 then
        PartCam.CFrame = CFrame.lookAt(PartCam.CFrame.Position, Character.Head.CFrame.Position)
        PartCam.Rotation = Vector3.new(0,0,PartCam.Rotation.Z)
    end
end)

Though, with what @Azul_Litt just did, that would be better instead.

1 Like

hmmm for some reason the camera type doesn’t change :pensive: for both of u @AmoraFolf @DasKairo

Try this:

local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local camera = workspace.CurrentCamera
local PartCam = workspace.Cam

camera.CameraType = Enum.CameraType.Fixed
camera.CFrame = PartCam.CFrame

task.wait(0.001)
print(Character.Name)
Character:WaitForChild("Head"):GetPropertyChangedSignal("Position"):Connect(function()
    local Head = Character:WaitForChild("Head")
	print(Head.Position)
	if Head.Position then
		print("e")
		PartCam.CFrame = CFrame.lookAt(PartCam.CFrame.Position, Character.Head.CFrame.Position)
		PartCam.Rotation = Vector3.new(0,0,PartCam.Rotation.Z)
	end
end)
1 Like

oh nvm after fixing it up a bit I got exactly what I wanted almost

the camera rotates inverse of what I want it too like if I move left the camera moves right so idk what to do i Multiplied by -1 but it just showed me the other side which is expected so idk

local Players = game:GetService("Players")
local PartCam = workspace.Cam

local player  = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()


character:WaitForChild("Humanoid"):GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if character.Humanoid.MoveDirection.Magnitude > 0 then
		workspace.CurrentCamera.CFrame = PartCam.CFrame
		PartCam.CFrame = CFrame.lookAt(PartCam.CFrame.Position, character.Head.CFrame.Position)
		PartCam.Rotation = Vector3.new(0,PartCam.Rotation.Y, 0)
		workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

	end
end)

it has to do with the rotation line idk

just trying for only the y rotation to move nothing else

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.