Scripting Help Needed!

Hey scripters,
I made this tween but it just spawns as the goal of the tween.

---// Variables
local Rep = game:GetService("ReplicatedStorage")
local Part = Rep:WaitForChild("Part")
local CurrentPartSize = Part.Size
local CurrentPartColor = Part.BrickColor
Part.Size = CurrentPartSize
Part.BrickColor = CurrentPartColor
--// Tweens
local TweenService = game.TweenService
local Info = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local Goal = {
    ["Size"] = Vector3.new (153.7, 38.7, 177.3),
    ["Color"] = Color3.fromRGB(151, 0, 0)
}
local StartTween = TweenService:Create(Part, Info, Goal)
--// Functions
local function NukeParticles()
Part.Parent = game.Workspace
StartTween:Play()
end
NukeParticles()

Can you help? It’s supposed to go from small to big with a change of colors, but instead when the the NukeParticles function starts, it’s already the goal.

Are you calling it right when the game starts? This could make it tween before you load in the game. Try putting a small yield like 2 seconds.

1 Like

Hm, I will try to put a wait function and/or an OnServerEvent before using the Tween.

--// Variables
local Rep = game:GetService("ReplicatedStorage")
local Part = Rep:WaitForChild("Part")
local CurrentPartSize = Part.Size
local CurrentPartColor = Part.BrickColor
local NukeEvent = Rep:WaitForChild("NukeLaunch")
Part.Size = CurrentPartSize
Part.BrickColor = CurrentPartColor
local DuplicatePart = Part:Clone()
DuplicatePart.Name = "PartClone"
--// Tweens
local TweenService = game.TweenService
local Info = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local Goal = {
	["Size"] = Vector3.new (153.7, 38.7, 177.3),
	["Color"] = Color3.fromRGB(151, 0, 0)
}
local StartTween = TweenService:Create(DuplicatePart, Info, Goal)
--// Functions
NukeEvent.OnServerEvent:Connect()
wait(2)
local function NukeParticles()
	DuplicatePart.Parent = game.Workspace
	wait(2)
StartTween:Play()
end
NukeParticles()

I am very bad at Lua programming because I had just started. I changed up to make it clone the part in ReplicatedStorage though.

If you’re trying to wait until an event fires then use the :Wait() method instead like this

RemoteEvent.OnServerEvent:Wait()
1 Like

Thanks for your help! It worked!

You gotta write; Game:GetService(“TweenService”)

1 Like

pretty sure :Wait() is deprecated, use :wait() instead

1 Like

Actually its the other way around

I actually didn’t know that thanks man