#Making sphere move left and right

1 messages · Page 1 of 1 (latest)

quiet ridge
#

I have a script to make the sphere move left and right and the script runs through the entire thing with no errors but the ball never actually does anything and just falls down.

local cframeList = {}
local alignPosition = script.Parent.AlignPosition
local a = true

if a == true then
    a = false
    table.insert(cframeList, script.Parent.Parent.D1.D1A.CFrame)
    table.insert(cframeList, script.Parent.Parent.D2.D2A.CFrame)
end



alignPosition.MaxVelocity = 30
platform.AlignOrientation.MaxAngularVelocity = 3
alignPosition.Position = cframeList[1].Position
platform.AlignOrientation.CFrame = cframeList[1].Rotation
platform.Anchored = false

while true do
    for i,_ in pairs(cframeList) do
        alignPosition.Position = cframeList[i].Position --Im grabbing the first thing out of my cframeList table since i will return an index
        platform.AlignOrientation.CFrame = cframeList[i].Rotation
        print("here")
        task.wait(2)
    end
    
    
    
    
end```
signal helm
#

what if you change CFrame to WorldCFrame

#

table.insert(cframeList, script.Parent.Parent.D1.D1A.WorldCFrame)
table.insert(cframeList, script.Parent.Parent.D2.D2A.WorldCFrame)

late vale
#

You could use math.sin() to get a cool wave effect

signal helm
#

isnt attachment cframe relative to the parent part though

#

im pretty sure you need to set the AlignPosition's position to the WorldCFrame

late vale
#

Just do Cframe.new(math.sin(os.tick), 0, 0)

quiet ridge
#

Im thinking its because I didnt use an attathcment 0 and 1

#

But I dont want to use this if I can avoid them cuz I wanna use the table so I can make a loop to move back and forth

signal helm
#

hm

#

I tested it and it worked for me so idk what else is wrong

quiet ridge
# signal helm

Damn yeah Im just really stumped and like overall im getting confused cuz theres like 3 diffrent ways I can do this too but this way is the best way

signal helm
#

Did you set the Attachment0 of the AlignPosition to the Center attachment?

quiet ridge
signal helm
#

and also set the Mode to OneAttachment

quiet ridge
#

Culd that be the issue

signal helm
#

yeah that should be the issue

#

just set Mode to OneAttachment

#

then click Attachment0 and set to the Center attachment

quiet ridge
signal helm
#

attachment one goes away if you set the mode to OneAttachment

quiet ridge
signal helm
#

i think so yeah

#

same thing

quiet ridge
#

lowkey dont know how to embed videos

#

but like its moving down and to the right

signal helm
#

you changed CFrame to WorldCFrame right?

quiet ridge
signal helm
#

put it to WorldCFrame otherwise it will go to the center of the world

#

which i think is what its doing

quiet ridge
signal helm
#

what is it doing now?

quiet ridge
#

same thing

signal helm
#

is it the same

#

hm

quiet ridge
#

this is my script right now

local cframeList = {}
local alignPosition = script.Parent.AlignPosition
local a = true

if a == true then
    a = false
    table.insert(cframeList, script.Parent.Parent.D1.D1A.WorldCFrame)
    table.insert(cframeList, script.Parent.Parent.D2.D2A.WorldCFrame)
end



alignPosition.MaxVelocity = 30
platform.AlignOrientation.MaxAngularVelocity = 3
alignPosition.Position = cframeList[1].Position
platform.AlignOrientation.CFrame = cframeList[1].Rotation
platform.Anchored = false

while true do
    for i,_ in pairs(cframeList) do
        alignPosition.Position = cframeList[i].Position --Im grabbing the first thing out of my cframeList table since i will return an index
        platform.AlignOrientation.CFrame = cframeList[i].Rotation
        print("here")
        task.wait(2)
    end




end```
signal helm
#

where are parts D1 and D2

#

in your game

quiet ridge
signal helm
#

oh wait

#

i think the first line is suppose to be
local platform = script.Parent

#

because you do platform.AlignOrientation

quiet ridge
#

That fixed it but like I dont get why

signal helm
#

Were you getting any errors before?

quiet ridge
#

If I change the position of my attatchment doesnt my ball stay fixed with it

quiet ridge
#

Originally it didnt give me errors for that

signal helm
#

no its the position inside alignPosition that moves the ball

quiet ridge
#

Im just really happy I fixed it

signal helm
#

well I think AlignPosition applies a force to the ball's attachment which also moves the ball basically

quiet ridge
#

This script took me like an hour and wasnt working so it was super frustarating

signal helm
#

oh well good its fixed now