I have a script that works fine but when I reset my character, it doesn’t work anymore
I need help!
[This problem appears in all my scripts]
local humrp = char:WaitForChild("HumanoidRootPart")
local hum = char:WaitForChild("Humanoid")
local part = workspace.Part
while true do
humrp.CFrame = CFrame.lookAt(humrp.Position, Vector3.new(part.Position.X, humrp.Position.Y, part.Position.Z))
task.wait()
end
This is happening due everytime the player die, the character is changed.
Basically you need to update the humrp & hum variables everytime the player character be spawned.
It works just fine if you put it in starter character scripts
or you can try this
local part = workspace.Part
while true do
local humrp = char:WaitForChild("HumanoidRootPart")
local hum = char:WaitForChild("Humanoid")
humrp.CFrame = CFrame.lookAt(humrp.Position, Vector3.new(part.Position.X, humrp.Position.Y, part.Position.Z))
task.wait()
end
local Player = game:GetService("Players").LocalPlayer
local part = workspace.Part
while true do
local char = Player.Character or Player.CharacterAdded:Wait()
local humrp = char:WaitForChild("HumanoidRootPart")
local hum = char:WaitForChild("Humanoid")
humrp.CFrame = CFrame.lookAt(humrp.Position, Vector3.new(part.Position.X, humrp.Position.Y, part.Position.Z))
task.wait()
end