Alright so basically what my script does is make your character face the direction the mouse is facing while the q key on your keyboard is being held down. I’ve made this post because I’m trying to find a better way to go about this.Here’s my code.
inputService.InputBegan:Connect(function(Key, GameStuff) if GameStuff and not CanClick then return end if Key.KeyCode == Enum.KeyCode.Q then CanClick = false Holding.Value = true end end) inputService.InputEnded:Connect(function(Key, GameStuff) if GameStuff then return end if Key.KeyCode == Enum.KeyCode.Q then CanClick = true Holding.Value = false end end) mouse.Move:Connect(function() if Holding.Value ~= true then return end Root.CFrame = CFrame.new(Root.Position, Root.Position + Vector3.new(mouse.Hit.lookVector.x, mouse.Hit.lookVector.y, mouse.Hit.lookVector.z)) wait(.1) end)
How would you guys go about this and what methods would you guys use to create a better version of this? All replies are appreciated as I’m an intermediate programmer trying to improve and i believe feedback on improving my code is one step closer to achieving that goal.