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

Why does the CFrame part of the script still not work?

Cframe expected got table is the error. Im making a game where you can click on an object and move it; im trying to include the ability to rotate it clockwise and counterclockwise but it still insists on not working , if you could help me in answers please do. Thankyou

game:GetService("UserInputService").InputBegan:Connect(function(input,gameprocessed)

if input.KeyCode == Enum.KeyCode.Q then

local X,Y,Z = mtarget.CFrame:toEulerAnglesXYZ()

--// if key q is pressed then rotate CC

mtarget.CFrame = CFrame * CFrame.Angles(math.rad(X),math.rad(Y+90),math.rad(Z))

end

end)

  

game:GetService("UserInputService").InputBegan:Connect(function(input,gameprocessed)

if input.KeyCode == Enum.KeyCode.E then

local X,Y,Z = mtarget.CFrame:toEulerAnglesXYZ()

--// if key e is pressed then rotate C

mtarget.CFrame = CFrame * CFrame.Angles(math.rad(X),math.rad(Y-90),math.rad(Z))

wait()

end

end)

mtarget ; mouse target / what player has clicked and is in control of rotating the object.

1 comment

0

i think u need to do CFrame = CFrame.new() and then continue on

1 answer

CFrame is a class and not an actual CFrame, in the same way that math is a class and not a number. I think you're looking for this:

mtarget.CFrame = mtarget.CFrame * CFrame.Angles(--[[arguments here]])

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