#CFrame look at not working with character

1 messages · Page 1 of 1 (latest)

alpine nacelle
#

I have a function in my module script to "respawn" the player by pivoting them to a part and making the cframe lookat the child of said part called LookAt . It pivots my character to the spawnpart I set but the look at never works and I always face the same direction.

function module.RespawnAtPart(player, part)
    local lookAt = part:WaitForChild("LookAt")
    
    local char:Model = player.Character or player.CharacterAdded:Wait()
    local hrp = char:FindFirstChild("HumanoidRootPart")
    local humanoid = char:FindFirstChild("Humanoid")
    
    humanoid.Health = 100
    
    if hrp then
        char:PivotTo(CFrame.new(part.Position, lookAt.Position))
        print("respawned from module")
    end
end```

```lua
local introNotCompleteSpawn = game.Workspace.SpawnPos:WaitForChild("IntroNotComplete")
--other stuff
respawn.RespawnAtPart(player, introNotCompleteSpawn)

I can confirm introNotCompleteSpawn is a valid instance and it has a child called LookAt that wherever I move LookAt nothing changes

Image shows me spawning in and lookAt in red

tulip saddle
#

You could try this.

RootPart.CFrame = CFrame.lookat(RootPart.Position, lookAt.Position)
mortal thicket
alpine nacelle