Hello. I’m trying to make a system where players can enter a Sound ID in the TextBox, click a button, and add it to a folder on the server. While writing the scripts, I ran into a problem: the server script doesn’t get the text from the TextBox and just outputs nothing or nil (depending on how you change the script). In addition, the script gives an error when trying to change the name of the sound (see below the code for all errors).
Here’s how I wrote this system:
-- Local script inside of a GUI.
local Gui = script.Parent
local DJui = Gui.Frame.DJ
DJui.ID.Add.MouseButton1Click:Connect(function()
if DJui.ID.Text == "" then
DJui.Output.Text = "ID can't be empty."
DJui.Output.TextColor3 = Color3.fromRGB(255, 38, 42)
end
local MarketplaceService = game:GetService'MarketplaceService'
local Success, Response = pcall(MarketplaceService.GetProductInfo, MarketplaceService, DJui.ID.Text)
if Success then
if Response.AssetTypeId == Enum.AssetType.Audio.Value then
if DJui.ID.Text ~= "" and DJui.Output.TextColor3 ~= Color3.fromRGB(255, 38, 42) then
local event = game.ReplicatedStorage.DJSongToServer
print(DJui.ID.Text)
event:FireServer(DJui.ID.Text)
end
end
end
end)
-- Server script inside of a ServerScriptService
local event = game.ReplicatedStorage.DJSongToServer
local folderChildren = game.Workspace.Ambience.CafeRadio:GetChildren()
local DJGamepass = 884995252
local DJ = {}
event.OnServerEvent:Connect(function(player, ID)
if table.find(DJ, player.Name) or game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, DJGamepass) then
ID = player.PlayerGui.MusicGui.Frame.DJ.ID.Text -- An attempt to make it receive the ID from the player's GUI.
print(ID) -- Still doesn't receive anything.
local Sound = Instance.new("Sound")
Sound.SoundId = "rbxassetid://"..ID
Sound.Parent = game.Workspace.Ambience.CafeRadio
Sound.Volume = 0.5
Sound.Name = game:GetService("MarketplaceService"):GetProductInfo(ID,Enum.InfoType.Asset).Name
-- Line 15
end
end)
Errors that occurred during the test:
11:42:27.973 Unable to cast string to int64 - Server - SongToServer:15
11:42:27.973 Stack Begin - Studio
11:42:27.973 Script 'ServerScriptService.SongToServer', Line 15 - Studio - SongToServer:15
11:42:27.973 Stack End - Studio
11:42:28.116 ▶ Failed to load sound rbxassetid://: HTTP 404 (Not Found) (x2) - Studio
-- Errors at line 12
Do you have any ideas on how to fix both of these errors? I would be very thankful!