I’m making a super simple custom overhead camera script and for some reason it randomly kills the player! I’m serious, the script could not be simpler, and for some reason it’s killing the player in a loop! I had this same problem a long time ago and I have no idea what could have caused it.
Code (StarterCharacterScripts)
local camera = game.Workspace:WaitForChild("Camera")
camera.CameraType = Enum.CameraType.Scriptable
local char = script.Parent or game.Players.LocalPlayer.CharacterAdded:Wait()
local hrp:Part = char:WaitForChild("HumanoidRootPart")
game["Run Service"].RenderStepped:Connect(function()
camera.CFrame = CFrame.new(Vector3.new(hrp.Position.X, script:GetAttribute("Distance"), hrp.Position.Z), hrp.Position)
end)
Edit: The same thing happens when I put it in StarterPlayerScripts and change the script.parent part to game.Players.LocalPlayer.Character
Are you sure it’s that script killing the player, cause I don’t see anything that would kill the player there. Changing the camera doesn’t affect the character in any way.
That’s this thing! All it does is change the camera and the character bugs out and dies as soon as its height changes. Is there another way that you know of to make an overhead camera?
I’m a little bit confused with “its height changes”, the character’s height? Why would the character’s height change by manipulating the camera unless it’s somehow binded to it.
The game right now is pretty barebones (there’s basically no other scripts), I tried an extremely similar script a while ago and the same thing happened.
Why are you changing the HRP’s position? You’re not supposed to mess with the character at all, just change the camera’s CFrame to be above the character.
Ok, if you copy the script just change the script:GetAttribute("Distance") part to 25 or any arbitrary number, or add an attribute to the script. Make sure it’s in StarterCharacterScripts
Managed to fix it and surprisingly it was the camera script, to be specific the formula you used to set the CFrame. Just replace it with this and it should work,
You’re welcome. I’m not 100% sure as to why but the way you were getting the angle to be pointed at the character was the cause, this part , hrp.Position)
This is likely a bug. I am able to consistently kill myself by changing my camera cframe in the command bar by using some specific ranges of valid values.
Strange it does not kill when I am knocked over in the ragdoll state.