Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

CFrame LookVector not changing???

local camcenter = workspace.CameraCenter -- this is a part that controls a camera
local cframe = camcenter.CFrame

local MaxIncrement = 10
local increment = 1

local uis = game:GetService("UserInputService")

uis.InputBegan:connect(function(input)
	print("InputDetected")
	if input.UserInputType == Enum.UserInputType.Keyboard then
		print("KeyboardInputDetected")
		if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.Up then
			print("WUPInputDetected")
			if (cframe.LookVector + Vector3.new(0, 0, increment)).Z < Vector3.new(0, 0, MaxIncrement).Z then
				print("Changing")
				cframe = CFrame.new(Vector3.new(0,0,0), cframe.LookVector + Vector3.new(0, 0, increment)) 
			end
		end
	end
end)

I am not getting any errors. The thing is that it only works once and then it freezes.

help please

1 answer

✓ Accepted answer

After experimenting with the code you provided, sometimes the new CFrame you change it to can have numbers that show up as "NAN" or not a number. These show up when you do something like divide 0 by 0. NAN came up for me with an unrotated block for me when I tried out your code, but it worked when I rotated the brick a bit first, I would say to try that.

4 comments

1

ok, thx! ill try it.

0

nope, did not help, but thank you anyhow

1

got it! the thing is that it change it by soooo little the change was unnoticable

0

glad I could help

This discussion is preserved as it was. New answers, comments, and votes are closed.