Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Character rotating with tool. How to fix this?

Asked by 5 years ago
Edited 5 years ago

I am trying to create a tool that rotates when the player clicks, and have found that when I rotate the tool using CFrames, it causes the player to rotate with the tool. I understand this is to due with the character being welded to the tool, but how do I fix this?

Here is my current script:

local tool = script.Parent
local main = tool.Handle
local m = game.Players.LocalPlayer:GetMouse()
local ready = true


m.Button1Down:Connect(function()
    if ready == true then
        main.CFrame = CFrame.new() * CFrame.fromEulerAnglesXYZ(math.pi,main.Orientation.Y, main.Orientation.Z)
    else

    end
end)

1 answer

Log in to vote
0
Answered by
memguy 161
5 years ago

When moving a tool while maintaining character's cframe, you should change tool grip instead. Example:

local tool = script.Parent
local main = tool.Handle
local m = game.Players.LocalPlayer:GetMouse()
local ready = true


m.Button1Down:Connect(function()
    if ready == true then
        main.Grip = CFrame.new() * CFrame.fromEulerAnglesXYZ(math.pi,main.Orientation.Y, main.Orientation.Z)
    else

    end
end)

By the way, it will not replicate to other players.

0
I figured that, would I be able to solve this with a Remote Function? MasonJames136 21 — 5y
Ad

Answer this question