If the player was standing at the star and the player presses ‘E’, then I want them to be able to walk forward or backwards, pulling or pushing the hand around. I have the “Pressing ‘E’” thing down, I just don’t know how I would position the player and make the hand move with them in such a manor, any suggestions?
Your rotation would probably have to looks something like this:
local arm = <your clock arm>
local pushing = true -- Set this to true when player begins pushing
repeat
arm.CFrame *= CFrame.Angles * direction-- Make the correct angles
task.wait()
until not pushing
Direction should be 1, 0 or -1. 1 would be holding W, -1 would be holding S and 0 would be nothing.
Is there any way that I could detect when and if the player starts to go left or right so I could stop turning the arm? Also, how would I keep the hand locked on the center so the player can’t just walk away with it?
Well, I plan on animating it, so the player grabs onto it, so it actually looks like they’re pushing it.
I started getting it to work, except that after a certain point, after the player keeps walking, it starts going the other way (Sorry for the bad quality, I used Roblox’s built in recording system):
The reason it is doing this is because I am doing using .MoveDirection.X to check for the direction:
if (_localHumanoid.MoveDirection.X < 0) then
direction = 1
elseif (_localHumanoid.MoveDirection.X > 0) then
direction = -1
end
The only problem is that, because it’s a circle, after I walk for so long it reverses. Is there a better way of getting the player’s direction?
(Also, I can’t just use ‘W’ and ‘S’ because I want this to be available on mobile)
You could compare the move direction with the humanoidRootParts look direction (or -ZVector). If they are somewhat aligned then they are moving forward