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

How to play a tween properly?

Asked by 2 years ago

So I'm currently trying to make a potion for my game, and I want it to make the player's character bigger.

local TweenService = game:GetService("TweenService")
local tool = script.Parent
local drink = tool.Drink
local drinkSound = tool["Drink Sound"]
local triggered = false

local function onActivated()
    if not triggered then
        triggered = true

        drinkSound:Play()

        local character = tool.Parent
        local humanoid = character.Humanoid

        local animTrack = humanoid:LoadAnimation(drink)
        animTrack:Play()

        for i, v in pairs(character:GetChildren()) do
            if v:IsA("Part") then
                local info = TweenInfo.new(
                    5,
                    Enum.EasingStyle.Sine,
                    Enum.EasingDirection.Out,
                    0,
                    false,
                    0
                )

                local goals = {
                    Size = Vector3.new(15, 15, 15);
                }

                local tween = TweenService:Create(v, info, goals)
            else
                -- ignore
            end
        end

        wait(1.5)
        triggered = false
    end
end

tool.Activated:Connect(onActivated)

For some reason, the tween I made doesn't play. Can somebody help me? Thank you.

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

I think it's because you didn't play the tween, maybe try this, it's at line 34.

-- Line 34
local tween = TweenService:Create(v, info, goals)
tween:Play() -- Added this, 
else
Ad

Answer this question