Unable to cast to array

Hey everyone, so I got this error and I don’t know how to fix it.

Here is the code:

local plr = game.Players.LocalPlayer
local TweenService = game:GetService("TweenService")

repeat task.wait() until plr:FindFirstChild("leaderstats")
repeat task.wait() until plr.leaderstats:FindFirstChild("Gems")

local GemSound = script.Gems

local ContentProvider = game:GetService("ContentProvider"):PreloadAsync(GemSound) -- // This is the thing that was saying unable to cast to array.

local Added = script.Parent.Added

local info = TweenInfo.new(
	1,
	Enum.EasingStyle.Cubic,
	Enum.EasingDirection.In,
	0,
	true,
	0
)

local goal = {
	BackgroundTransparency = 0,
	TextTransparency = 0
}

local Tween = TweenService:Create(Added, info, goal)


function update()
	local newValue = plr.leaderstats.Gems.Value
	
	script.Parent.Frame.TextLabel.Text = tostring(newValue)
end

update()

plr.leaderstats.Gems.Changed:Connect(function()
	Tween:Play()
	GemSound:Play()
	update()
end)

I tried things that could possibly fix it but It didn’t work out that well, and also I’m learning about content providers.

Wrap it in curly braces
{GemSound}

1 Like

That just broke the script. It didn’t throw any errors for some reason.

I don’t know how it broke but PreloadAsync yields, for future reference.