Get cframe realitve to player?

this is my code right now, but it is realtive to the world space, so when i turn, it can go from left to right, because the x dosn’t change when i turn

local origin = firepoint *, 0, 0)

There is a Property called ToObjectSpace

Uh, property? I think you mean function.

yeah, sorry


like this?

	local origin = firepoint + CFrame:ToObjectSpace(,0,0))

It’s a member method which means the CFrame left of the colon needs to be an actual CFrame. If you are trying to get the position relative to the character, it should be the humanoid root part’s CFrame.

local origin = firepoint + character.HumanoidRootPart.CFrame:PointToObjectSpace(,0,0))

Actually can you clarify are you rotating a cframe or a vector3 relative to the character?

uhh not sure, as long as it maakes it realtive to the player and is on the right i guess

also the firepoint is mouse.origin

Usually what people want is a vector in world space transformed to object space, which is what my example shows. This means if the player is standing at (10,0,0) and facing down the X+ direction, a world position (15,0,0) would be transformed to (0,0,-5), since -Z is forward and the player is facing directly at the point.

PointToObject space makes this “relative” transformation. VectorToObject space does something silimar but only changes the rotation to be relative, not the position. VectorToObject space is used in scenarios where you would use PointToObject but your input is a normal, direction, or size.

hmm it seems to not work??
sometimes it works soethmes it dosn’t

nvm it dosn’t work, if i rotate my character where the bullet come from changes

Hard to tell without seeing code but it sounds like you are doing it backwards. If you want a player-relative position to place a bullet at, you do the opposite using :PointToWorldSpace().

local firepos =,0,0) --Relative to the HRP
bullet.Position = character.HumanoidRootPart.CFrame:PointToWorldSpace(firepos)
local mousePosition = mouse.Hit.Position
		local firepoint = mouse.Origin.Position
		debounce = false
local firepoint = mouse.Hit
local characterspace = - rootpart.Position) * firepoint.Rotation

Try this?

mouse.hit? won’t that make it go from where my mouse is pointing at?

Mouse.Hit is where the mouse is pointing, it’s a CFrame.

is theer a much simpler way to do this? what if i just use the position of mouse.origin as a referance?

Not sure what you’re trying to do, because Mouse.Origin is at the Camera’s Position.

yea but this is a first person shooter, so no difference at all