I'm trying to get a part of a tool to spin when clicked, I have the script and basically I gave it a motor Joint where it stays put then made it so when you click it makes another motor joint that spins it but it doesn't seem to be working, whats my problem?
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(0,0,0) w.C1 = CFrame.new(-3,0.65,0) local w2 = Instance.new("Weld") w2.Parent = Rotate1 w2.Part0 = Rotate1 w2.Part1 = tool.Blade2 w2.C0 = CFrame.new(0,0,0) w2.C1 = CFrame.new(-3,-0.65,0) local Handle = tool.Handle local Rotate1 = tool.Rotate1 while true do local rotate = Instance.new("Motor",game.JointsService) rotate.Part0 = Handle rotate.Part1 = Rotate1 rotate.C0 = CFrame.new(0,0,0) rotate.C1 = CFrame.new(-3,0,0) wait(0.01) end function OnClicked(Mouse) local rotate1 = Instance.new("Motor",game.JointsService) rotate1.Part0 = tool.Handle rotate1.Part1 = tool.Rotate1 rotate1.C0 = CFrame.new(0,0,0) rotate1.C1 = CFrame.new(-3,0,0) rotate1.MaxVelocity = math.rad(20) rotate1.DesiredAngle = math.rad(360) end function OnEquipped(Mouse) Mouse.Button1Down:connect(OnClicked) end
OnClicked
and OnEquipped
are not defined until after the infinite while loop on line 26, so the connection never gets made.