I need the player to rotate in the same direction the GUI ImageLabel faces.
I’ve tried setting the humanoidrootpart’s Y orientation value to the GUI’s rotation angle, however am unsure as to how I would structure/script his.
The GUI’s script is basically getting a second GUI’s position on the screen and converting it to an angle and setting that as the rotation.
1 Like

You can edit the Root located in the lower torso of character
local Gui = script.Parent
local MovementFrame = Gui:WaitForChild("Frame")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart") :: BasePart
local Camera = workspace.CurrentCamera
local Mouse = Player:GetMouse()
local LowerTorso = Character:WaitForChild("LowerTorso")
local Root = LowerTorso:WaitForChild("Root") :: Motor6D
function GetRotation()
local X = Mouse.X - MovementFrame.AbsolutePosition.X
local Y = Mouse.Y - MovementFrame.AbsolutePosition.Y
return math.atan2(Y, X)
end
function OnRenderStep()
Camera.CFrame = CFrame.new(HRP.Position) * CFrame.new(0, 30, 0) * CFrame.Angles(math.rad(-90), 0, 0)
local Rotation = GetRotation() + 90
MovementFrame.Rotation = math.deg(Rotation)
Root.C1 = CFrame.Angles(0, Rotation, 0)
end
game:GetService("RunService").RenderStepped:Connect(OnRenderStep)
Here is the one i made i know its so bad but you got the idea
1 Like
Would this work with R6? Since the lowertorso only applies to R15 characters
Oh you are right it can be in torso but i dont know i will check it when i come home
I found another way you can just change the cframe of humanoidrootpart so it also works for R6
local Gui = script.Parent
local MovementFrame = Gui:WaitForChild("Frame")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart") :: BasePart
local Camera = workspace.CurrentCamera
local Mouse = Player:GetMouse()
function GetRotation()
local MovementVector = Vector2.new(
MovementFrame.AbsolutePosition.X - Mouse.X,
MovementFrame.AbsolutePosition.Y - Mouse.Y
).Unit
return math.atan2(MovementVector.Y, MovementVector.X)
end
function OnRenderStep()
Camera.CFrame = CFrame.new(HRP.Position) * CFrame.new(0, 30, 0) * CFrame.Angles(math.rad(-90), 0, 0)
local Rotation = GetRotation() - 90
MovementFrame.Rotation = math.deg(Rotation)
HRP.CFrame = CFrame.new(HRP.Position) * CFrame.Angles(0, -Rotation, 0)
end
game:GetService("RunService").RenderStepped:Connect(OnRenderStep)
Also i just realized that changing the root joint on blocky avatars is glitching
My script managed to work after adding the HRP.Cframe section and tweaking it a little.
Thanks for the help.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.