playAnimation (not working)

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?

1 Like

What type of Scripts are both scripts?

1 Like

The playAnimation script is a localscript and the other also

1 Like

Oh. Because you use a remote event to fire to the client. This won’t really work since RemoteEvent are Client to Server and Server To Client communication. In your case you should use A bindable Event. And use the :Fire() function and .Event function.

1 Like

Thanks, because i´m very new can you send me the full code so i can replace it?

1 Like

There’s not much of new coding, in the ReplicatedStorage add a bindableevent whereever BuildAnimation is, and remove the RemoteEvent to it and replace the name of the BindableEvent to BuildAnimation and change theses line to:
playAnimation Script:

remotes.BuildAnimation:Fire(toSpawn)

Animation Script:

ReplicatedStorage.Remotes:WaitForChild("BuildAnimation").Event:Connect(function(Model)
	print("called")
	AnimateBuild(Model)
end)

1 Like

Sorry sorry, i dont know how to add an bindableevent because i never worked with that. can you explain a little bit how to?

Just like how you add a RemoteEvent, you type its name and click it.
image

image
Like this?

no no no. Put the Bindable Event inside Remotes. Remove the BuildAnimation Event (unless you need for server to client). Rename the Bindable Event to BuildAnimation

I did everything its not working and i dont have an error in output

Hmmm, did you change the script accordingly?

Yes, i changed everything you told me. Do you want to join Team Create?

I guess, but only for the issue.

Okay, what is your username? so you can help me with the issue

image

I added you on Roblox so you can help me

image

I gave you permission to help.

Its in TycoonModule and TycoonClient