Hello everyone, this is my first devforum post and I need your help!
Currently im building an tycoon but my animations if you buy something are not showing, this is my playAnimation script:
if playAnimation then
for _, v in toSpawn:GetDescendants() do
if v:IsA("BasePart") then
v.CanCollide = false
local particle = script.PurchaseParticle:Clone()
particle.Parent = v
particle:Emit(80/#toSpawn:GetDescendants())
task.delay(3, function()
particle:Destroy()
end)
end
end
task.wait(0.01)
remotes.BuildAnimation:FireClient(player, toSpawn)
end
My Animation Script is
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local MainGui = PlayerGui:WaitForChild("MainGui")
local Info = MainGui:WaitForChild("Info")
local MoneyDisplay = Info:WaitForChild("Frame")
local MoneyDisplayTextLabel = MoneyDisplay:WaitForChild("MoneyDisplay")
local RateDisplay = Info:WaitForChild("RateDisplay")
local RateDisplayLabel = RateDisplay:WaitForChild("rate")
local remotes = ReplicatedStorage:WaitForChild("Remotes")
local Modules = ReplicatedStorage:WaitForChild("Modules")
local FormatNumber = require(Modules:WaitForChild("FormatNumberAlt"))
local Rng = Random.new()
local function AnimateBuild(Model)
for _, v in Model:GetChildren() do
if v:IsA("BasePart") or v:IsA("UnionOperation") then
local OriginalCFrame = v.CFrame
local OriginalSize = v.Size
local OriginalTransparency = v.Transparency
local PositionOffset = Vector3.new(Rng:NextNumber(-2, 2), Rng:NextNumber(-2, 2), Rng:NextNumber(-2, 2))
local RotationOffset = CFrame.Angles(Rng:NextNumber(-3, 3), Rng:NextNumber(-3, 3), Rng:NextNumber(-3, 3))
v.CFrame = v.CFrame * CFrame.new(PositionOffset) * RotationOffset
v.Transparency = 1
TweenService:Create(v, TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out), {CFrame = OriginalCFrame}):Play()
TweenService:Create(v, TweenInfo.new(0.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Transparency = OriginalTransparency}):Play()
end
end
end
ReplicatedStorage.Remotes:WaitForChild("BuildAnimation").OnClientEvent:Connect(function(Model)
print("called")
AnimateBuild(Model)
end)
remotes:WaitForChild("UpdateCurrency").OnClientEvent:Connect(function(Amount, Rate)
MoneyDisplayTextLabel.Text = FormatNumber.FormatStandard(Amount).." $"
RateDisplayLabel.Text = FormatNumber.FormatCompact(Rate).." / s"
end)
Does someone know how I can fix this problem?