So I made a GUI and put this script in it.
01 | local okbutton = script.Parent.TextButton |
02 |
03 | function onClicked(id) |
04 | id = script.Parent.TextBox.Text |
05 | local music 1 = Instance.new( "Sound" ) |
06 |
07 | music 1. Parent = game.Workspace |
08 |
09 | music 1. SoundId = "http://www.roblox.com/asset/?id=" ..id |
10 |
11 | wait( 1 ) |
12 | music 1 :Play() |
13 | end |
14 |
15 | script.Parent.TextButton.MouseButton 1 Click: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:
01 | local okbutton = script.Parent.TextButton |
02 | local remote = script.Parent.Remote |
03 |
04 | frame = script.Parent.Parent.Frame |
05 | frame.Draggable = true |
06 | frame.Active = true |
07 | frame.Selectable = true |
08 |
09 | function onClicked(id) |
10 | script.Parent.Remote:FireServer() |
11 | end |
12 |
13 | script.Parent.TextButton.MouseButton 1 Click:Connect(onClicked) |
The RemoteScript (just a normal Script)
01 | script.Parent.Remote.OnServerEvent:Connect( function (id) |
02 | id = script.Parent:WaitForChild( "TextBox" ) |
03 | local music 1 = Instance.new( "Sound" ) |
04 |
05 | music 1. Name = "Music1" |
06 |
07 | music 1. Parent = game.Workspace |
08 |
09 | music 1. SoundId = "http://www.roblox.com/asset/?id=" ..id.Text |
10 |
11 | wait( 1 ) |
12 | music 1 :Play() |
13 | 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