So I’m currently working on a Simulator game, where you have different Boomboxes that rewards you with cash. I’ve made a script that makes the whole Boomboxes sway from side to side while you’re holding down a button, but I’m trying to make the whole pet/boombox change in size as well, but I don’t seem to make it work. I’ve pasted the code below, but it doesn’t change the size of all the parts in the “model.” The way the Boombox is built is shown in the picture below here as well.
-- Create the link to the remote events
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local petDanceEvent = ReplicatedStorage.Events.PetEvents:WaitForChild("PetDance")
-- When the remote events fire these functions will respectively run
petDanceEvent.OnServerEvent:Connect(function(plr, bool)
plr.Character.Pet.Mid.ParticleEmitter.Enabled = bool
plr.Character.Pet.Mid.Sound.Playing = bool
plr.Character.Pet:SetAttribute("Dance", bool)
-- Animate the size of the Pet part
local pet = plr.Character.Pet
local smallSize = Vector3.new(1, 1, 1)
local largeSize = Vector3.new(2, 2, 2)
local tweenInfo = TweenInfo.new(
1, -- duration (in seconds)
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out
)
-- Create a function to animate the size of the Pet part and its children
local function animateSize(part, size)
local tween = game:GetService("TweenService"):Create(part, tweenInfo, {Size = size})
tween:Play()
-- Use recursion to animate the size of all the children of the part
for _, child in pairs(part:GetChildren()) do
animateSize(child, size)
end
end
if bool then
-- Animate the size of the Pet part and its children to the large size
animateSize(pet, largeSize)
else
-- Animate the size of the Pet part and its children to the small size
animateSize(pet, smallSize)
end
end)