I am trying to clone a part into the workspace and then tweening all the parts
It is cloning but is not tweening
local Workspace = game:GetService("Workspace")
local RepStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local warpPart = RepStorage.CircleMeshWarp
while true do
task.wait(2)
local warpClone = warpPart:Clone()
warpClone.Mesh.Scale = Vector3.new(2, 0.01, 2)
warpClone.Parent = Workspace
end
Workspace.ChildAdded:Connect(function(child)
if child.Name == "CircleMeshWarp" then
local mesh = child:FindFirstChild("Mesh")
if mesh then
local TweenData = TweenInfo.new(3, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)
local Tween = TweenService:Create(mesh, TweenData, {Scale = Vector3.new(10, 0.01, 10)})
Tween:Play()
else print("Didn't Work!!")
end
end
end)
Wrap your code in a thread and it should run well while being above the event. The reason it doesn’t work the way you did it is that when something got added the event wasn’t set so it missed it. Using a thread makes the code run side by side with the one you’re currently running
Ex:
task.spawn(function()
while true do
task.wait(2)
local warpClone = warpPart:Clone()
warpClone.Mesh.Scale = Vector3.new(2, 0.01, 2)
warpClone.Parent = Workspace
end
end)