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

Help me with player rotation?

Asked by 10 years ago

I have previously posted this, but here is my question once again. I was trying to make a script in which your character faces your mouse all the time but when I tried this, the controls became defective.

1 answer

Log in to vote
-1
Answered by 10 years ago

I use this script.

Tool = script.Parent
gyro = Instance.new("BodyGyro")
script.Gyro.Value = gyro 

onMouseMove=function(mouse)
    vCharacter = Tool.Parent
    if vCharacter ~= nil then 
        local tp = vCharacter.Humanoid.TargetPoint
        tp = Vector3.new(tp.X,Tool.Parent.Torso.Position.Y,tp.Z) 
        local dir = (tp - Tool.Parent.Torso.Position).unit
        local spawnPos = Tool.Parent.Torso.Position
        local pos = spawnPos + (dir * 1)
        script.Gyro.Value.cframe = CFrame.new(pos,  pos + dir)
    end
end

onEquipped=function(mouse)
    for i,k in pairs(Tool.Parent.Torso:GetChildren()) do
        if k:IsA("BodyGyro") then 
            k.Parent=nil    
        end
    end
    wait(0.1) 
    script.Gyro.Value.Parent = Tool.Parent:findFirstChild("Torso")
    script.Gyro.Value.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
    mouse.Move:connect(function() onMouseMove(mouse) end)
end 

onUnequipped=function()
    script.Gyro.Value.Parent = nil 
    wait(0.01) 
    for i,k in pairs(Tool.Parent.Torso:GetChildren()) do
        if k:IsA("BodyGyro") then 
            k.Parent=nil    
        end
    end
end 

Tool.Equipped:connect(onEquipped)
Tool.Unequipped:connect(onUnequipped)
0
This doesn't work, there is no "Gyro" in this tool. What kind of object should "Gyro" be? xolbStudios 127 — 10y
0
Sir, please answer my question. xolbStudios 127 — 10y
Ad

Answer this question