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

How do I make it so that a tween plays upon found in workspace?

Asked by 4 years ago
01local Clickd = script.Parent.ClickDetector
02local Button = script.Parent
03local RS = game:GetService("ReplicatedStorage")
04local EndFolder = RS:WaitForChild("End")
05local Pillar = EndFolder.Pillar
06local Radius = 250
07local Baseplate = game.Workspace.Baseplate
08local -- nil value
09local Y = 0
10local -- nil value
11 
12 
13Clickd.MouseClick:Connect(function()
14    print("Worked!")
15    local ClonedPillar = Pillar:Clone()
View all 49 lines...

When the cloned Pillar appears in workspace, why does it not slowly levitate? It just appears on the baseplate and the tween does not play

2 answers

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

You could wrap the tween in a function and play it whenever a pillar is added to the workspace.

workspace.ChildAdded:Connect(function(child) if child.Name == "Pillar" then local TweenService = game:GetService("TweenService") local TweeningInfo = TweenInfo.new(

01        5, -- Length       
02        Enum.EasingStyle.Quad, -- EasingStyle
03        Enum.EasingDirection.Out, -- EasingDirection
04        0, -- Repeat count
05        false, -- Repeatable
06        1.5 -- Delay
07 
08    )
09 
10    local PartProperties = {
11        Position = Vector3.new(0,250,0)}
12    local Tween = TweenService:Create(child,TweeningInfo,PartProperties)
13    Tween:Play()
14end

end

0
It did not work, no errors :C RandyN56 23 — 4y
0
I forgot to play the Tween lol, should work now LeedleLeeRocket 1257 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Hello again, I guess it's not solved so I'll help you out. The script isn't working because 1. the loop doesn't allow it to pass through the tween and 2. the tween will play to the original part, not cloned part. Fixing those problems isn't that hard. Here's an example how to result those problems.

01local Clickd = script.Parent.ClickDetector
02local Button = script.Parent
03local RS = game:GetService("ReplicatedStorage")
04local EndFolder = RS:WaitForChild("End")
05local Pillar = EndFolder.Pillar
06local Radius = 250
07local Baseplate = game.Workspace.Baseplate
08local -- nil value
09local Y = 0
10local -- nil value
11 
12local TweenService = game:GetService("TweenService")
13local TweeningInfo = TweenInfo.new(
14 
15    5, -- Length       
View all 47 lines...

Hopefully you understand it and have fun with this script!

Answer this question