Hello.

I've been trying to get my Trello enabled music player to work, but everything I tried does not work. The entire code works perfectly fine during normal studio testing. But on a game server, :TweenPosition does not work. However, the music still plays.

Here's my code:

local Background = script.Parent.Background

function create(class, parent)
	local cre = LoadLibrary("RbxUtility").Create
	return function(properties)
		local inst = cre(class)(properties)
		inst.Parent = parent
		
		return inst
	end
end

local function shuffleTable(t)
	math.randomseed(tick())
	assert(t, "shuffleTable() expected a table, got nil")
	local iterations = #t
	local j
	for i = iterations, 2, -1 do
		j = math.random(i)
		t[i], t[j] = t[j], t[i]
	end
end

local Songs = {
	
}

local SongNum = 0

local http = game:GetService("HttpService")
local songs = http:JSONDecode(http:GetAsync("https://api.trello.com/1/lists/58fc97dd846a0a0b60d304e1/cards"))
for _, v in pairs(songs) do
	if v.name:match(":") ~= nil then
		local s, f = string.find(v.name, ":")
		table.insert(Songs, string.sub(v.name, f + 1))
		game:GetService("ContentProvider"):Preload("rbxassetid://" .. string.sub(v.name, f + 1))
		print(Songs[#Songs])
	end
end

shuffleTable(Songs)

while wait() do
	SongNum = SongNum + 1
	if SongNum > #Songs then
		SongNum = 1
	end
	Background:TweenPosition(UDim2.new(0.5, -140, 0, 10), "Out", "Back", 0.5)
	Background.CurrentSong.Text = game:GetService("MarketplaceService"):GetProductInfo(Songs[SongNum]).Name
	game.ReplicatedStorage.Music.Value = game:GetService('MarketplaceService'):GetProductInfo(Songs[SongNum]).Name
	wait(5)
	Background:TweenPosition(UDim2.new(0.5, -140, -0.5, 10), "Out", "Back", 0.5)
	local Song = "rbxassetid://" .. Songs[SongNum]
	create("Sound", script.Parent.Parent.Parent) {
		Volume = 0.4;
		SoundId = Song;
		Name = "Music";
	}
	local Sound = script.Parent.Parent.Parent:FindFirstChild("Music")
	Sound:Play()
	wait(120)
	Sound:Stop()
	wait()
	Sound:Destroy()
end


4 comments

0

Use WaitForChild some variables

0

Make sure you're using a localscript. Scripts can't tween stuff.

0

Hmm, is it a normal script?

0

I tried script and a LocalScript, both do not work.