New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

Rotate a player towards the mouse hit position?

Asked by 3 months ago

Hey everyone, so recently i've been trying to create a beam, that starts from the player and goes towards the mouse. I want the player to also be able to rotate towards the mouse as the beam is being fired.

Here's my current progress:

The problem is that whenever I try to roate the player, the player glitches out,

I just need a push in the right direction on how rotate the player the correct way. So far, the script creates the beam and updates the beam's CFrame.

1 answer

Log in to vote
Answered by
Prestory 1390 Moderation Voter
3 months ago
Edited by User#24403 3 months ago

Here is an example of how you can do it i suggest editing it and changing it to your needs for example if your using a key hold function replace it with the loop.

local Char = game.Players.LocalPlayer.Character
local mouse = game.Players.LocalPlayer:GetMouse()
local RootPart = Char:WaitForChild('HumanoidRootPart')

local BG ="BodyGyro")
BG.CFrame = RootPart.CFrame
BG.MaxTorque =, math.huge, math.huge)
BG.P = 30000
BG.Parent = RootPart

while true do
    RootPart.BodyGyro.CFrame =, mouse.Hit.Position)    
Where is this put? What type of script is this? Cvllapse 30 — 3mo
LocalScript if you wan't to test if it works you can place it in StarterGui Prestory 1390 — 3mo
Right, I read someone suggest using Body Gyro's, the only thing is that sometimes it would fling the character when the character is looking up. Any suggestions on how to fix that? awsomemike4 3 — 3mo
Anchor the humanoid root part to fix it Prestory 1390 — 3mo

Answer this question