I think you should make some variables like this:
and then use UserInputService to check.
local UIS = game:GetService("UserInputService")
local runSvc = game:GetService("RunService")
local holdingShift = false
local breakLoop = false
UIS.InputBegan:Connect(function(input, event)
if event then return end
if input.KeyCode == Enum.KeyCode.LeftShift then
breakLoop = false
UIS.InputBegan:Connect(function(input, event)
if event then return end
if input.KeyCode == Enum.KeyCode.A then
while wait(0.1) do
if breakLoop then break end
yourPart.Orientation = yourPart.Orientation + Vector3.new(1,0,0) -- I'm not so good at direction stuff so it might be wrong
end
elseif input.KeyCode == Enum.KeyCode.A then
while wait(0.1) do
if breakLoop then break end
yourPart.Orientation = yourPart.Orientation + Vector3.new(-1,0,0) -- I'm not so good at direction stuff so it might be wrong
end
elseif input.KeyCode == Enum.KeyCode.A then
while wait(0.1) do
if breakLoop then break end
yourPart.Orientation = yourPart.Orientation + Vector3.new(0,1,0) -- I'm not so good at direction stuff so it might be wrong
end
elseif input.KeyCode == Enum.KeyCode.A then
while wait(0.1) do
if breakLoop then break end
yourPart.Orientation = yourPart.Orientation + Vector3.new(0,-1,0) -- I'm not so good at direction stuff so it might be wrong
end
end
end)
end
end)
UIS.InputEnded:Connect(function(input, event)
if event then return end
if input.KeyCode == Enum.KeyCode.LeftShift then
breakLoop = true
end
end)
Set the skulls cframe to CFrame.new(SkullPosition, (LocalCamera.CFrame * CFrame.new(0,0,-100)).p) This will make the part follow the center of your screen.
I found this post that has just about what I need, but I cannot implement it for the life of me. I always get close.
--[[CurrentObjectOffset is the position and rotation relative
to the camera when the object is first picked up.
]]
function UpdateBodyMovers()
if LiftingObject then
if (CurrentObject.Position - Root.Position).Magnitude > GrabRadius then
LiftingObject = false
DropObject()
else
CurrentObject.Mover.Position = (Camera.CFrame * CurrentObjectOffset.Position)
CurrentObject.Gyro.CFrame = Camera.CFrame * CurrentObjectOffset - CurrentObjectOffset.Position
if ShiftDown and CurrentObject then
if not W and not S or not A and not D then
if W then
end
if S then
end
if D then
end
if A then
end
end
end
end
end
end
This is the code I currently have. The problem I was having with implementing the code from the post linked above:
I was able to make the object rotate relative to the camera when pressing W, but when I would move it around, the object’s rotation would be relative to the world space, and not the camera anymore like the video I initially posted.
I need the object to rotate towards the camera, and when it is moved around, have its rotation be relative to the camera as well.
Someone please ATTEMPT to help. I am desperate. If you have more questions I will try to answer them.