Weird problem with RemoteEvents

Alright so, I have been working on a UI-based music system. And I need to transfer multiple values via a RemoteEvent from one LocalScript to an Serverscript. But whenever I do this, the values just somehow mix up and im just left confused.

Localscript values and value transmission:

local isplaying = false
local songid = ""
local loop = false
local volume = 1
local yes = 2

//some code

event:FireServer(isplaying, songid, loop, volume, yes)

The Serverscript and value receiver:

event.onServerEvent:connect(function(isplaying, songid, loop, volume, yes)
print(songid)
		print(isplaying)
		print(songid)
		print(loop)
		print(volume)
		print(yes)
end)

And this is the console output I get when printing these values:
https://gyazo.com/11ebbbeccc253a2122b03d86f34e739a

The first parameter passed in OnServerEvent is the player who fired the remote. So when you try and print “IsPlaying” you get your player “Flauschi_XD” printed out instead of the bool you want.

What you should be doing is something like this:

event.onServerEvent:connect(function(player, isplaying, songid, loop, volume, yes)
        print(Player)
		print(isplaying)
		print(songid)
		print(loop)
		print(volume)
		print(yes)
end)

Note there may be a typo!
Hopefully this helps and goodluck!

2 Likes

Still didn’t work. The values stay still in the same mixed up way, but now the “Flauschi_XD” is missing and got replaced by a “false” value.

Player would be an object, so it should be

print(Player.Name)

Can you post the updated server event connection code block?

1 Like

There you go:

event.onServerEvent:connect(function(player, isplaying, songid, loop, volume)
	if songid ~= music.SoundId then
		print(songid)
		print(isplaying)
		print(loop)
		print(volume)
		music.SoundId = songid
		music.Playing = true
		music.TimePosition = 0
	end

Well you’re not printing the player or printing the parameters in order.

1 Like

This does not change the fact that the “loop” value contains the Id when i try to use it.

Are you sure that when you are firing the remote event on the client, you’re sending the data in the correct order?

I’ve done a demo using the exact code provided and it works fine.

Setup:

Output:
Demo3

1 Like

I fixed it by just redoing the entire script in the end.
Thanks for trying to help tho.