Hello, i am not sure how to name a object through a textbox. I tried an remoteevent but it seems that the object name is still blank. Here are the scripts
ServerScript:
local replicatedStorage = game:GetService("ReplicatedStorage")
local remotes = replicatedStorage.Remotes
game.Players.PlayerAdded:Connect(function(player)
remotes.CreateSong.OnServerEvent:Connect(function()
local CMUI = player.PlayerGui.Misc.CreateMusic
local newSongValue = Instance.new("BoolValue", player.Bools.Songs)
newSongValue.Name = CMUI.SongName.Value
end)
end)
LocalScript:
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.SongName.Value = script.Parent.Parent.SongTTL.Text
game.ReplicatedStorage.Remotes.CreateSong:FireServer(player)
end)
Remove the playeradded, OnServerEvent’s first parameter always is the player who fired the event, so put player in its brackets
You change the value on the client and try to get it on the server, the value isn’t replicated so it wont notice the change, you’d have to pass in the songname through the FireServer, and remove player from the FireServer as well since it’s done automatically
That’s correct, where songName is the name of the song in question, Make sure to include this as a parameter on the OnServerEvent as well so you cna use it
Now, i put the mention of songName but it still didn’t work
ServerScript
remotes.CreateSong.OnServerEvent:Connect(function(player, songName)
local CMUI = player.PlayerGui.Misc.CreateMusic
local newSongValue = Instance.new("BoolValue", player.Bools.Songs)
newSongValue.Name = CMUI.SongName.Value
end)
LocalScript
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local songName = script.Parent.Parent.SongName.Value
script.Parent.Parent.SongName.Value = script.Parent.Parent.SongTTL.Text
game.ReplicatedStorage.Remotes.CreateSong:FireServer(songName)
end)
You store the value into a variable too early because next line you change the value, you don’t really need a variable in this case, just pass in the value of SongName into the FireServer directly
Your OnServerEvent doesn’t use songName, it still tries to get it directly, which can’t work due to replication, use songName where you try to get the value directly
You don’t need to catch the remote event inside playeradded. Player is automatically passed in when the remote event is fired. That is your problem, you are catching it multiple times from every player.
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local songName = script.Parent.Parent.SongName
songName.Value = script.Parent.Parent.SongTTL.Text
game.ReplicatedStorage.Remotes.CreateSong:FireServer(songName.Value)
end)