So I made a GUI and put this script in it.
local okbutton = script.Parent.TextButton function onClicked(id) id = script.Parent.TextBox.Text local music1 = Instance.new("Sound") music1.Parent = game.Workspace music1.SoundId = "http://www.roblox.com/asset/?id="..id wait(1) music1:Play() end script.Parent.TextButton.MouseButton1Click:Connect(onClicked)
Well, it's not working. Can somebody help me fix this?
Make sure it's a LocalScript. You also need to use RemoteEvents for such. RemoteEvents send commands from the player to the server. For example, you click the button and it sends an imput to the server saying to do such. You can find more here: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
Hi there! I tried that with this LocalScript:
local okbutton = script.Parent.TextButton local remote = script.Parent.Remote frame = script.Parent.Parent.Frame frame.Draggable = true frame.Active = true frame.Selectable = true function onClicked(id) script.Parent.Remote:FireServer() end script.Parent.TextButton.MouseButton1Click:Connect(onClicked)
The RemoteScript (just a normal Script)
script.Parent.Remote.OnServerEvent:Connect(function(id) id = script.Parent:WaitForChild("TextBox") local music1 = Instance.new("Sound") music1.Name = "Music1" music1.Parent = game.Workspace music1.SoundId = "http://www.roblox.com/asset/?id="..id.Text wait(1) music1:Play() end)
And I get this error every time: Failed to load sound http://www.roblox.com/asset/?id=: Unable to download sound data (x2) - Studio