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

Need an explanation here?

Asked by 8 years ago

So I was trying to do some kind of part rotationing porpotional to the camera's CFrame. Well I did'nt go so well, in fact I really did'nt expect this to happen. It was origally supposed to rotate a part porpotatinal to the camera ( in 1st person mode). You see nothing errors and the game definitly does something .... Anyways, here's the script:

player = game.Players.LocalPlayer
char = player.Character
Instance.new("Part",workspace).Position = Vector3.new(0,10,0)
Weld = Instance.new("Weld",char['Left Arm'])
Weld.Part0 = workspace.Part
Weld.Part1 = char['Left Arm']
Weld.C0 = CFrame.new(0,0,0)*CFrame.Angles(0,math.rad(-90),0)

game:GetService("RunService").RenderStepped:connect(function()
    if char ~= nil then
        Weld.C0 = CFrame.new(Weld.C0.p)+(workspace.CurrentCamera.CFrame.lookVector/.98) --this part I don't get why works (since you can't divide a # by Vector3, right?
    end
end)

I don't wanna give away exactly what happens... so I'm asking to to test my script by opening a new place and putting it into a local script. If nothing happens, well I guess I'm completly insane. But if you can, please explain why it does it's thing, and what I can do to fix it. THX!!

0
You can divide Vectors with another Vector. Ex; workspace.CurrentCamera.CFrame.lookVector/Vector3.new(.98,.98,.98). Each .98 being whatever you want. SimplyRekt 413 — 8y
0
You are right that you can't divide a number by a Vector3, but you can divide a Vector3 by a number (divides each component by that number) which is what you are doing. BlackJPI 2658 — 8y
0
I have no idea what you're trying to do here and there is nothing wrong with vector division/multiplication with number. ZarsBranchkin 885 — 8y

Answer this question