Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

CFrame LookVector not changing???

Asked by 3 years ago
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

Log in to vote
1
Answered by
HEMAN_9 70
3 years ago

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.

1
ok, thx! ill try it. R_LabradorRetriever 198 — 3y
0
nope, did not help, but thank you anyhow R_LabradorRetriever 198 — 3y
1
got it! the thing is that it change it by soooo little the change was unnoticable R_LabradorRetriever 198 — 3y
0
glad I could help HEMAN_9 70 — 3y
Ad

Answer this question