I’m trying to make a local script for a music changer I’m trying to make.
I’m using a textbox to put in an ID to change it but since the changes are client sided, it cannot change it.
As in the video seen below, I put in an ID but and press the button to set it and in the console it returns a very professional text meaning that there’s nothing in it.
local uis = game:GetService("UserInputService")
local clicked = script.Parent.Parent.Frame.RUSHOVERDRIVE
clicked.MouseButton1Click:Connect(function()
uis.InputBegan:Connect(function(i, c)
if c then return end
if i.KeyCode == Enum.KeyCode.N then
script.Parent.Visible = not script.Parent.Visible
end
end)
end)
local setmusic = game:WaitForChild("StarterGui"):WaitForChild("RUSHOVEDRIVEgui"):WaitForChild("Frame"):WaitForChild("LocalScript"):WaitForChild("Placeholder")
local ignoremusic = game:WaitForChild("StarterGui"):WaitForChild("RUSHOVEDRIVEgui"):WaitForChild("Frame"):WaitForChild("LocalScript"):WaitForChild("Sound")
local putinid = script.Parent.TextBox.Text
local rep = game:GetService("ReplicatedStorage"):FindFirstChild("MusicChanged")
script.Parent.SUBMIT.MouseButton1Click:Connect(function()
if putinid == "" then
print("erm what the sigma.")
else
setmusic.SoundId = "rbxassetid://"..putinid
rep:Fire("Changed")
print("yep, got that brotha!")
end
end)
That’s the script I’m working with. Any help would be appreciated! :–D
the main issue is that you’re grabbing the value of the TextBox (putinid) way too early. Right now, you’re getting the text once when the script first runs, not when the button is actually clicked. That’s why it prints empty or old values.
also, since you’re trying to change a sound on the server via a LocalScript, just keep in mind: if the actual Sound object is on the server, you’ll need to fire a RemoteEvent to the server to change it there. Clients can only affect sounds locally unless the server handles the change.
local submitButton = script.Parent.SUBMIT
local textBox = script.Parent.TextBox
local sound = script.Parent.Parent:FindFirstChild("Sound") -- add your sound name
local rep = game:GetService("ReplicatedStorage")
local musicChanged = rep:FindFirstChild("MusicChanged")
submitButton.MouseButton1Click:Connect(function()
local putinid = textBox.Text
if putinid == "" then
print("erm what the sigma.")
else
if sound then
sound.SoundId = "rbxassetid://"..putinid
print("Sound ID set locally!")
end
if musicChanged then
musicChanged:FireServer("Changed", putinid)
end
print("yep, got that brotha!")
end
end)
If you’re using a RemoteEvent, you’ll need to handle the server-side part with a RemoteEvent.OnServerEvent connection that actually changes the sound for everyone. Otherwise, only the local player hears it. also, be careful with naming things like "LocalScript" in your hierarchy. might be good to rename those for clarity.
Silly me, I forgot to mention that the gear’s activation is also handled by a local script, so a RemoteEvent won’t work. I guess I could use a BindableEvent instead?
So TL;DR there’s no server script in this