I have this code where a player can input an id and play a song. Whenever I try to concatenate the id with a string, it says attempt to concatenate string with Instance.
Local Script:
local Event = game.ReplicatedStorage.DJEvent
local Box = script.Parent.TextBox
local Enter = script.Parent.Enter
local WarnFrame = game.Players.LocalPlayer.PlayerGui.ScreenGuis.WarningFrame
local WarnLabel = WarnFrame.TextLabel
local MS = game:GetService("MarketplaceService")
local Success, Error
function Warn(Text)
if WarnFrame.Visible == false then
WarnLabel.Text = Text
WarnFrame.Visible = true
wait(3)
WarnFrame.Visible = false
WarnLabel.Text = ""
end
end
Enter.MouseButton1Click:Connect(function()
if Box.Text ~= "" and tonumber(Box.Text) ~= nil then
Success, Error = pcall(function()
Info = MS:GetProductInfo(tonumber(Box.Text))
end)
if Success then
if Info.AssetTypeId == 3 then
Event:FireServer(Info.AssetId, Info.Name)
else
Warn("Please type an audio ID!")
end
else
Warn("Error loading ID!")
end
elseif tonumber(Box.Text) == nil then
Warn("Please type a number!")
end
end)
Server Script:
local Sound = script.Parent.ClubMusic
local Event = game.ReplicatedStorage.DJEvent
Event.OnServerEvent:Connect(function(ID, Name)
local Song = "rbxassetid://"..ID
Sound.SoundId = Song
Sound:Play()
end)