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

Question with using BodyAngularVelocity?

Asked by 10 years ago

I'm trying to make a script that uses BodyAngularVelocity to spin bricks. To make it simple I named the bricks after the colors of the rainbow (Red, Orange, Yellow, Green, Blue, Purple). I do not think there is a problem with the code itself, but how it's working. It does exactly what I want it to do, it un-anchors the bricks, makes the TopSurface a hinge (so it stays together), and then adds the BodyAngularVelocities. Also, the bricks are vertically aligned on top of each other, with Purple being the bottom brick. However, there are two problems (although one is minor): 1. Even though the parts are 2x4 studs, you can still see the hinges THROUGH them, although this may be a studio glitch and not a scripting one. 2. The bricks still aren't spinning, even though everything is being made and working. However, it does work if you manually raise the brick up then lower it back into position.

Here is the snippet of code:

s.Purple.TopSurface = "Hinge"
s.Blue.TopSurface = "Hinge"
s.Green.TopSurface = "Hinge"
s.Yellow.TopSurface = "Hinge"
s.Orange.TopSurface = "Hinge"

s.Blue.Anchored = false
s.Green.Anchored = false
s.Yellow.Anchored = false
s.Orange.Anchored = false
s.Red.Anchored = false

local angr = Instance.new("BodyAngularVelocity", s.Red)
angr.Name = "angr"
angr.angularvelocity = Vector3.new(0,-20,0)

local ango = Instance.new("BodyAngularVelocity", s.Orange)
ango.Name = "ango"
ango.angularvelocity = Vector3.new(0,70,0)

local angy = Instance.new("BodyAngularVelocity", s.Yellow)
angy.Name = "angy"
angy.angularvelocity = Vector3.new(0,-8,0)

local angg = Instance.new("BodyAngularVelocity", s.Green)
angg.Name = "angg"
angg.angularvelocity = Vector3.new(0,200,0)

local angb = Instance.new("BodyAngularVelocity", s.Blue)
angb.Name = "angb"
angb.angularvelocity = Vector3.new(0,-40,0)
end

Answer this question