Ad
Log in to vote
0

Tweening a part CFrame doesn't seem to work properly? [SOLVED!]

Asked by 1 month ago
Edited 1 month ago

I started a project with a friend and I'm having trouble tweening CFrame's in a skill. The idea is for the stick to grow straight in the hand of the charater, using tweening I managed to make it grow, but resizing the Z axis makes it grow both ways so to compensate I wanted to move the stick forward like this creating the effect of the stick growing to one direction. The problem is that the code just doenst seen to do anything at all.

local info = TweenInfo.new(0.2)

local tween1 = tService:Create(rSkillEffectClone.PoleGrow,info,{Size = Vector3.new(11+(Yeoui.Value*1.5), 0.3+(Yeoui.Value*0.1), 0.3+(Yeoui.Value*0.1))})

local growCorrection = rSkillEffectClone.PoleGrow.CFrame * CFrame.new(0,0,(Yeoui.Value*1.5)/2)

local tween2 = tService:Create(rSkillEffectClone.PoleGrow,info,{CFrame = growCorrection})

tween1:Play()
tween2:Play()

The problem is on the growCorrection, no matter how I change the values, even if I add high values (like 10 studs) on Y axis, the stick doesn’t move. Only tween1 seems to work, no error messages appears on the output.

2 answers

Log in to vote
0
Answered by
KixWater 111
1 month ago
Edited 1 month ago

You didn't give the TweenInfo any properties except the time to tween.

Try this:

local info = TweenInfo.new(
    0.2,
    Enum.EasingStyle. --The style you want then do a comma
    Enum.EasingDirection. --The Direction you want then do a comma
        --This is the number of times you want to repeat the tween then do a comma
        --This is if you want to reverse the tween, if you chose no to repeat do false put do true
        --This is the number of seconds that you want your tween to be delayed by
)

local function tween()
    local tween1 = tService:Create(rSkillEffectClone.PoleGrow,info,{Size = Vector3.new(11+  (Yeoui.Value*1.5), 0.3+(Yeoui.Value*0.1), 0.3+(Yeoui.Value*0.1))})

    local growCorrection = rSkillEffectClone.PoleGrow.CFrame * CFrame.new(0,0,  (Yeoui.Value*1.5)/2)

    local tween2 = tService:Create(rSkillEffectClone.PoleGrow,info,{CFrame =            growCorrection.CFrame})

    tween1:Play()
    tween2:Play()
end

tween()

If this doesn't help, please comment below this!

0
TweenInfo will default the rest, this isn't the issue. Ziffixture 6786 — 1mo
0
I don't think that's the problem as Tween1 works fine. And it's like Ziffixture said, if I don't specify anything everything will be in the default settings thaylerfg 30 — 1mo
0
Well I was wondering why you were setting "growCorrection" CFrame even though you set it in the variable. Is growCorrection a part or what? KixWater 111 — 1mo
0
growCorrection isnt a part, just a variable with the math. In line 15 of your script you spelled "CFrame = growCorrection.CFrame" but it should be just "CFrame = growCorrection" cuz the variable is just a CFrame value thaylerfg 30 — 1mo
0
Oh, ok. KixWater 111 — 1mo
Ad
Log in to vote
0
Answered by 1 month ago
Edited 1 month ago

I finally made it work, it got a little messy but these changes in the code led me to the desired result :)

local goal = {}

goal.Size = rSkillEffectClone.PoleGrow.Size + Vector3.new((Yeoui.Value*1.5),(Yeoui.Value*0.1),(Yeoui.Value*0.1))

goal.CFrame = rSkillEffectClone.PoleGrow.CFrame * CFrame.new((Yeoui.Value*1.5)/2,0,0)

local info = TweenInfo.new(0.2)

local tween1 = tService:Create(rSkillEffectClone.PoleGrow,info,goal)

tween1:Play()

I also did some changes on the skill effect model but i dont think its relevant

Answer this question