So I have a GUI in which a player can enter their sound ID for it to change the sound of the horn. However, it isn't working and is only changing the sound ID to the "rbxassetid://" part and doesn't include what the user entered. Here is my script:
repeat wait() until script:FindFirstAncestorOfClass("PlayerGui") local player = script:FindFirstAncestorOfClass("Player").Name local userboat = script.Parent.Parent.Parent.Ship.Value local seat = userboat.VehicleSeat local musicID = script.Parent.Parent.TextBox.Text script.Parent.MouseButton1Click:Connect(function() print("submitted sound") seat.Horn.SoundId = "rbxassetid://" .. musicID print("sound submitted") end)
Your issue is the fact that you declared musicID
as a constant; meaning that it will capture the state of which it was in after immediately being loaded, and will not reconfigure to any new input. Instead, you should capture the Text upon the MouseButton1Click
signal:
--// Ensure this is a LocalScript within the GUI local TextBoxInput = script:FindFirstAncestorOfClass("TextBox") local Button = script.Parent local Seat = script:FindFirstAncestor("Ship").Value.VehicleSeat --// This pathway is redundant, please reformat Button.MouseButton1Click:Connect(function() local SoundID = tonumber(TextBoxInput.Text) Seat.Horn.SoundId = "rbxassetid://"..SoundID end)
Server scripts cannot obtain info from TextBoxes. You'll need to use RemoteFunctions and a LocalScript to do this.
Edited
repeat wait() until script:FindFirstAncestorOfClass("PlayerGui") local player = script:FindFirstAncestorOfClass("Player").Name local userboat = script.Parent.Parent.Parent.Ship.Value local seat = userboat.VehicleSeat script.Parent.MouseButton1Click:Connect(function() local musicID = script.Parent.Parent.TextBox.Text print("submitted sound") seat.Horn.SoundId = "rbxassetid://"..musicID -- You put spaces here print("New horn sound ID: "..musicID) end)
If this helped please accept this answer.
All the best,
PrismaticFruits