I'm working on a Command which plays music globally and Roblox keeps outputting this following output.
ServerScriptService.EventFunctions:72: attempt to concatenate local 'AudioId' (a userdata value)
the code is as follows:
On Server Script
--// Local Variables local PlayMusicEvent = game:GetService("ReplicatedStorage"):WaitForChild("PlayMusic") --// OnServerEvent PlayMusicEvent.OnServerEvent:Connect(function(AudioId) local S = Instance.new("Sound") S.Playing = true S.Volume = 1 S.SoundId = "rbxassetid://" .. AudioId S.Name = "AddedMusic" S.Parent = game.Workspace end)
On Client LocalScript
--// Local Variables local Event = game:GetService("ReplicatedStorage"):WaitForChild("PlayMusic") local AudioIDField = script.Parent.Parent.MusicIdFieldFrame.MusicIdField --// FireServer game.ReplicatedStorage.PlayMusic:FireServer(AudioIDField.Text)
I haven't a clue why it keeps saying that local 'AudioId' is a userdata value whenever the Event is fired is a really straight forward script pass the ID to the server to then create the Sound Object and put the SoundId the user picked. Can anyone else spot why this happens?
By default the 1st parameter is the Player object who fired the remote, this means the script thinks AudioId is the player, try adding another parameter before AudioId to specify the player:
PlayMusicEvent.OnServerEvent:Connect(function(Player, AudioId)