Hello there, Developers!
I am having a bit of trouble with CFrames. I have likely forgotten something basic about rotation, but I would like your help to figure it out. Any help is appreciated!
What is my problem?
Currently, I am attempting to make a chair spin with the keys A & D, but it is not moving as expected.
Video: Gyazo
Local script:
local event = nil
local RS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local centre = game.Workspace.Throne.PrimaryPart
local aDown = false
local dDown = false
UIS.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.A then
aDown = true
end
if input.KeyCode == Enum.KeyCode.D then
dDown = true
end
end)
UIS.InputEnded:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.A then
aDown = false
end
if input.KeyCode == Enum.KeyCode.D then
dDown = false
end
end)
game.Workspace.Throne.Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if game.Workspace.Throne.Seat.Occupant == nil then
if event ~= nil then
event:Disconnect()
event = nil
end
return
end
local occupant = game.Workspace.Throne.Seat.Occupant
local player = game.Players:GetPlayerFromCharacter(occupant.Parent)
if player == nil then return end
if whitelist[player.UserId] == nil then return end
RS.Heartbeat:Connect(function(delta)
if aDown then
print("ADOWN!")
centre.CFrame = CFrame.new(centre.Position) * CFrame.Angles(centre.Orientation.X, centre.Orientation.Y - (35 *delta), centre.Orientation.Z)
elseif dDown then
print(centre.CFrame.Rotation.Y)
centre.CFrame = CFrame.new(centre.Position) * CFrame.Angles(centre.Orientation.X, centre.Orientation.Y + (35 *delta), centre.Orientation.Z)
print(" D DOWN")
end
end)
end)
Don’t mind the mess. I know there are incomplete parts, but at the moment I am just working on the rotation and will fix those later.
For context; the player is given network ownership of the chair parts that are connected with a WeldConstraint to the main part which is being moved.
Thanks for your help!