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

CFrame motor help?

Asked by 8 years ago

I've been working on a tool thats like a mini helicopter that when you left click it starts to spin and fly around and move towards where the mouse cursor is and then when you release the blades stop spinning and fall back down towards the ground. The problem I get is that I can't get it to rotate on the hinge continuously and to stop when I release the mouse button. This is my script so far. Rotate1 is connected to the handle by the way.

Updates: I've been able to get the part to spin on the y axis but I haven't been able to make it so it stays put until its been clicked then after its been clicked it stays spinning until the mouse is released and if I put the tool away and then bring it up again the piece I'm rotating falls off. I've been able to weld everything but the rotating block which is Rotate1 and the Handle together, whenever I weld those it welds them just fine but doesn't spin at all. The Blades which are like the helicopter blades that are attached to the rotational brick also seem to be rotated in the wrong direction then how I built the model of the tool. I Know exactly what I want it to do, I want the tool to stay stationary when the mouse isn't being clicked but when it is clicked I want it to start spinning the motor until the Mouse is not being clicked anymore then to stop when it is not being clicked anymore.

player = game.Players.LocalPlayer
tool = script.Parent
Rotate1 = tool.Rotate1
Wing1 = game.StarterPack.Wing1
Handle = tool.Handle

local tool = script.Parent 

local w = Instance.new("Weld") 
w.Parent = Rotate1
w.Part0 = Rotate1
w.Part1 = tool.Blade1
w.C0 = CFrame.new(3,-0.65,0)
w.C1 = CFrame.new(0,0,0)

local w2 = Instance.new("Weld")
w2.Parent = Rotate1
w2.Part0 = Rotate1
w2.Part1 = tool.Blade2 
w2.C0 = CFrame.new(3,0.65,0)
w2.C1 = CFrame.new(0,0,0)

local Handle = tool.Handle
local Rotate1 = tool.Rotate1

local motor = Instance.new("Motor", game.JointsService)
motor.Part0 = Handle
motor.Part1 = Rotate1
motor.C0 = CFrame.new(3,0,0) * CFrame.Angles(0,math.rad(90),0)
motor.C1 = CFrame.new(0,0,0) * CFrame.Angles(0,math.rad(90),0)
motor.MaxVelocity = math.rad(5)
        motor.DesiredAngle = math.rad(360)

function OnClicked()

    end

function OnEquipped(Mouse)  
    Mouse.Button1Down:connect(OnClicked)
end


0
Can you fix the numbering 1 - 40 in your code, please? Goulstem 8144 — 8y

Answer this question