hi. I am getting desperate. I’m just throwing words around in the script and I have no idea what I’m doing anymore. I keep getting warnings that say "Text is not a valid member of Player “Players.ROSKAA123"” like WDYM I NEVER TOLD U TO GET TEXT FROM PLAYERS???
so, what exactly is the problem here? and how do i fix it???
Local script =
game.Workspace:WaitForChild("USICPLAYER")
game.Workspace.USICPLAYER:WaitForChild("SOURCE")
local nuts = script.Parent.Parent.TextBox
local Song = game.Workspace.USICPLAYER.SOURCE.Sound
local remEvent = game.ReplicatedStorage.Depression
Song.SoundId = "rbxassetid://"..nuts.Text
nuts:GetPropertyChangedSignal("Text"):Connect(function()
remEvent:FireServer(nuts.Text)
end)
Server script:
game.Workspace:WaitForChild("USICPLAYER")
game.Workspace.USICPLAYER:WaitForChild("SOURCE")
local nuts = script.Parent.Parent.TextBox
local hi = game.Workspace.USICPLAYER
local Song = game.Workspace.USICPLAYER.SOURCE.Sound
local remEvent = game.ReplicatedStorage.Depression
Song.Playing = true
script.Parent.MouseButton1Click:connect(function()
remEvent.OnServerEvent:Connect(function(nuts,Text)
Song.SoundId = "rbxassetid://"..nuts.Text
Song:Play()
end)
end)
Im sorry if there’s somethinmg really weird going on im so tired and i just want to get done with this.
That’s because you’re sending a string and not the textbox object itself to the server script, so the line where you set the SoundId should look like this:
and this is wrong since you are only sending one argument???
so your server script should be like this instead.
game.Workspace:WaitForChild("USICPLAYER")
game.Workspace.USICPLAYER:WaitForChild("SOURCE")
local nuts = script.Parent.Parent.TextBox
local hi = game.Workspace.USICPLAYER
local Song = game.Workspace.USICPLAYER.SOURCE.Sound
local remEvent = game.ReplicatedStorage.Depression
Song.Playing = true
script.Parent.MouseButton1Click:connect(function()
remEvent.OnServerEvent:Connect(function(nuts)
Song.SoundId = "rbxassetid://"..nuts
Song:Play()
end)
end)
oh and also why are you handling the MouseButton1Click in the server script?
it should be:
Local script detects when player click → send remote to server → server receives it and then play the sounds
i think because the code is organized wrong, you should do
local script:
local button = script.Parent -- your button
local textbox = script.Parent.Parent.TextBox -- your textbox
local remEvent = game.ReplicatedStorage.Depression
button.MouseButton1Clicked:Connect(function()
remEvent:FireServer(textbox.Text)
end)
server:
local remEvent = game.ReplicatedStorage.Depression
remEvent.OnServerEvent:Connect(function(player, id)
song.SoundId = "rbxassetid://"..id
end)
local usic = workspace:WaitForChild("USICPLAYER")
local source = usic:WaitForChild("SOURCE")
local song = source:WaitForChild("Sound")
local nuts = script.Parent.Parent:WaitForChild("TextBox")
local rs = game:GetService("ReplicatedStorage")
local re = rs:WaitForChild("remEvent")
nuts:GetPropertyChangedSignal("Text"):Connect(function()
if tonumber(nuts.Text) then
local soundId = math.round(tonumber(nuts.Text))
re:FireServer(soundId)
end
end)
local usic = workspace:WaitForChild("USICPLAYER")
local source = usic:WaitForChild("SOURCE")
local song = source:WaitForChild("Sound")
local button = script.Parent
local rs = game:GetService("ReplicatedStorage")
local re = rs:WaitForChild("remEvent")
button.MouseButton1Click:Connect(function()
re.OnServerEvent:Connect(function(player, text)
song.SoundId = "rbxassetid://"..text
song:Play()
end)
end)
You should probably be making sure that a valid ID has been inputted. Also why are you using a server script inside a ScreenGui?
local usic = workspace:WaitForChild("USICPLAYER")
local source = usic:WaitForChild("SOURCE")
local song = source:WaitForChild("Sound")
local nuts = script.Parent.Parent:WaitForChild("TextBox")
local button = script.Parent --check this and other references are correct
local rs = game:GetService("ReplicatedStorage")
local re = rs:WaitForChild("remEvent")
button.MouseButton1Click:Connect(function()
if tonumber(nuts.Text) then
local soundId = math.round(tonumber(nuts.Text))
re:FireServer(soundId)
end
end)
local usic = workspace:WaitForChild("USICPLAYER")
local source = usic:WaitForChild("SOURCE")
local song = source:WaitForChild("Sound")
local rs = game:GetService("ReplicatedStorage")
local re = rs:WaitForChild("remEvent")
re.OnServerEvent:Connect(function(player, text)
song.SoundId = "rbxassetid://"..text
song:Play()
end)
Everything related to the Gui should be handled on the client-side in the single local script, all the server script should do is play the Sound instance. In this case I would move the server script to the ServerScriptService folder.