The script below is Localscript and is in StarterCharacterScripts.
-- Services --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
-- Variables --
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local Remote = game.ReplicatedStorage.RemoteEvents.FireBallEvent
local Mouse = plr:GetMouse()
-- Settings --
local Debounce = true
local Key = 'Q'
local Animation = Instance.new("Animation")
Animation.AnimationId = 'rbxassetid://2593868235'
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
local KeyPressed = Input.KeyCode
if KeyPressed == Enum.KeyCode[Key] and Debounce and Char then
Debounce = false
local LoadAnimation = Char.Humanoid:LoadAnimation(Animation)
LoadAnimation:Play()
-- View --
local player = game.Players.LocalPlayer
local character = player.Character
local torso = character.HumanoidRootPart
local mouse = player:GetMouse()
local ev = mouse.Move:Connect(function()
character.Humanoid.AutoRotate = false
torso.CFrame = CFrame.new(torso.Position, mouse.Hit.p*Vector3.new(1,0,1) + torso.Position*Vector3.new(0, 1, 0))
end)
wait(.5)
ev:Disconnect()
character.Humanoid.AutoRotate = true
Remote:FireServer(Mouse.Hit)
wait(2)
Debounce = true
end
end)
And the script below is what I tried to make player turn more smoothly.
-- Services --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
-- Variables --
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local Remote = game.ReplicatedStorage.RemoteEvents.FireBallEvent
local Mouse = plr:GetMouse()
-- Settings --
local Debounce = true
local Key = 'Q'
local Animation = Instance.new("Animation")
Animation.AnimationId = 'rbxassetid://2593868235'
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
local KeyPressed = Input.KeyCode
if KeyPressed == Enum.KeyCode[Key] and Debounce and Char then
Debounce = false
local LoadAnimation = Char.Humanoid:LoadAnimation(Animation)
LoadAnimation:Play()
-- View --
local player = game.Players.LocalPlayer
local character = player.Character
local torso = character.HumanoidRootPart.Position
local mouse = player:GetMouse()
local ev = mouse.Move:Connect(function()
character.Humanoid.AutoRotate = false
local part = CFrame.new(torso.Position)
local goal = {}
torso.CFrame = CFrame.new(Mouse.Hit.p*Vector3.new(1,0,1) + torso.Position*Vector3.new(0, 1, 0))
local tweenInfo = TweenInfo.new(5)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
wait(3)
ev:Disconnect()
character.Humanoid.AutoRotate = true
Remote:FireServer(Mouse.Hit)
wait(2)
Debounce = true
end)
end
end)
Yep it didn't work. I don't even know how TweenService work in the first place. I need a solution for this thing to work.

1 comment
Thanks. I only want humanoid to rotate to mouse only once when you press Q.