TweenService having issues

So, I’m stuck on this from two days, this tween wont start in any way:

goal = {}
goal.CFrame = CFrame.new(Base.Position, (Base.CFrame + Base.CFrame.RightVector * 50).p)
tweenInfo = TweenInfo.new(
(90/(script.Parent.Orientation.Y * (script.Parent.Orientation.Y^0/10))), – Time
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
-1
)
rotate = game:GetService(“TweenService”):Create(Base,tweenInfo,goal)
rotate:Play()

Why is the repeat count set to -1?

Doing that it is supposed to loop indefinitely.

of course it doesn’t, Roblox doesn’t know how to handle this
image
to be honest, i don’t know what you were trying to do there either, since you have “– Time” behind it

Did some tests and it appears if the part’s Y orientation is 0 the time of the tween is set to infinity

Edit: the tween works if the y orientation is not 0

–Time is a comment, and printing the result of that, gave me 12 if the orientation is equal to 70, I need that to do rotation angular speed based on a valve rotation, so that isn’t the problem, I then tried to set the cframe it didn’t work neither, there something that blocks or doesn’t start the script.

(Base.CFrame + Base.CFrame.RightVector * 50).p

You should use (Base.CFrame + Base.CFrame.RightVector * 50).Position here instead. .p is deprecated.

local goal = {CFrame = CFrame.new(Base.Position, (Base.CFrame + Base.CFrame.RightVector * 50).Position)}

local tweenInfo = TweenInfo.new(
                (90/(script.Parent.Orientation.Y * (script.Parent.Orientation.Y^0/10))), -- Time
                Enum.EasingStyle.Linear, -- Easing Style
                Enum.EasingDirection.In, -- Easing Direction
                -1 -- run indefinetly
)

rotate = game:GetService(“TweenService”):Create(Base,tweenInfo,goal)
rotate:Play()

I cleaned up to code a bit to make it easier to read :doh:

Edit: Are there any errors in the output?

1 Like

hold up, i just noticed; why are you trying to divide 0?
image

1 Like

No, even changing the cframe without tweening didn’t work, the part I’m trying to move is the part0 of many weld constraints and has a bodyposition in it. There’s no error. EDIT: It’s a body velocity, not position.

That was an error, fixing that wouldn’t fix the error, btw I fixed it.

Ok let’s do some basic mathematics. That’s the math you do:

90/(script.Parent.Orientation.Y * (script.Parent.Orientation.Y^0/10))

So the first thing the script will do is script.Parent.Orientation.Y^0. This part will always be 1 as no matter which number squared to 0 will be 1. Next thing it’ll do is dividing 1 by 10 which is equal to 0.1.

(script.Parent.Orientation.Y^0/10)
So this part will always give 0.1.

Now the problem is that when script.Parent.Orientation.Y = 0 and the the other part always gives 0.1 (I know that this is actually redundant) (script.Parent.Orientation.Y * (script.Parent.Orientation.Y^0/10)) will be 0. And you cannot divide 90 by 0. That’s actually impossible and causes the error.

I fixed that, it was an error on parenthisis, the problem is that the cframe wont change, tweened, in a bodygyro or not tweened it wont just change.

it really doesn’t change the fact WHERE you put a 0, if you divide or multiply at any point by 0, the end result will always be 0, you can have as many brackets as you want

Yea n^0 is 1 regardless of what n is (assuming its a regular number)
Seems that x * (x^0/10) is x * (x^0)/10 which is just x/10 (from x * 1/10) so it is really just
900/x (from 90/(x/10))

Yea that’s right^^ I read it wrong. My fault

Ok then, let’s say the orientation.Y is -70, so it’s like this: (90/((-70 * (-70^0)/10))) = (90/((-70 * -1)/10)) = (90/(70/10)) so it is 90/7 that is about 12, here’s the correction.
EDIT: I’m aware that N^0 does ever 1, but N*N^0 always returns the number with a positive sign. I needed that because the time can’t be negative. But now the issue is not that, the issue is that the script wont change that cframe tweened or not.

But if script.Parent.Orientation.Y is 0 it’ll still end up in a error as you can’t divide 90 by 0.

2 Likes

math.abs exists, also what you said is incorrect.
N*N^0 is just N
(-2)^0 is still 1, you can’t just magically put a negative sign outside of where you perform a substitution. Your equation is still 900 / Orientation.Y
This means that time will be negative if the orientation is negative (and Infinity at 0 as aforementioned).

Ok then I’ll use bodygyro for that, but the problem now is that I can’t change the part’s cframe from script, in studio’s command bar it worked.