Not receiving RemoteEvent

Hi! I’m trying to create preferences for a GUI (themes and stuff). I have a localscript that will send the prefernces through a remote event to a script in serverscriptservice that stores the data when the localplayer leaves. For some reason this wasn’t working so I added prints so that I could tell if it was going through or not. Turns out it wasn’t ever reaching the server script. No errors outputted!
Local script:

game.Players.PlayerRemoving:Connect(function(plr)
	
	if plr == game.Players.LocalPlayer then
		
		print("See you later!", plr.UserId) --Prints
		
		game.ReplicatedStorage:WaitForChild("AdminInfo"):FireServer(Vals:WaitForChild("AdminLvl").Value, MoreVals:WaitForChild("Theme").Value,  MoreVals:WaitForChild("DarkLight"), "Test")
		
		print("Sent Data") --Prints
		
	end
	
end)

Server script:

game.ReplicatedStorage:WaitForChild("AdminInfo").OnServerEvent:Connect(function(plr, adminlvl, theme, DarkLight, userid)
	
	print(theme, DarkLight, adminlvl, userid) --Does not print.
	
	local SaveThis = {
	
		adminlvl,
		
		theme,
		
		userid,
		
		DarkLight
		
	}
	
	Store:SetAsync(plr.UserId .."-AdminPreferenceTestA", SaveThis)
	
end)

Both those scripts don’t have the full code, but the code I provided was the only needed part.

1 Like

should not be used in local scripts. Same with PlayerAdded.

Let me try something new I guess. I’ll tell you the results.

those events can be used in local scripts, but what your doing should be done on the server, is the data being stored client side or server side??

In addition to what L7_M said, though this is less pressing of an issue, it is not a good practice to let a LocalScript manage important data such as what ‘adminlvl’ appears to be. LocalScripts can be hacked. Never trust a LocalScript with important data.

It should never be used in local scripts though, as they run when the client joins the game, thus are pointless.

thats not true what your saying, for example in my game i keep a list of others players data and i remove it when they leave, just because u dont have a use doesnt mean its pointless

It’s being stored on the server side. I’m not new to datastores; I wouldn’t use them if I were.

if its store server side then just do this on the server:

game.Players.PlayerRemoving:Connect(function(player)
      --get the player data here and save it
end

is it stored in a table or value objects

I would do that, but the values are being manipulated on the client side, then being sent to the server to be stored. Also, it’s a table made up of strings and numbers that came from values in the client.

The client should not be able to send information to the server to be stored.

Well that’s how I’ve been doing it with this project.

That is easily exploitable and users will be able to set their own data to be stored.

i advise you change it because clients can save anything they want, this system can be easily hacked instead what i recommend you do is have a data module and have respective functions to add player data to a server data table when then join, and remove it and save it when they leave.

I understand you guys, but I’m not asking for a way to exploit proof my scripts. I want to know why it’s not working.

I don’t know why you would want to make your scripts exploitable. Someone could easily (and I mean very easily) do whatever they want with the datavalues.

oh i just figured out why when the player leaves that event wont get ran locally beccause they would have left, thats why you do data saving on the server, you would only use that event locally if you need to detect if other players leave not the client themselves

I don’t want to make my scripts exploitable, but my main concern isn’t exploiting as of now it’s why this isn’t working.

Oh! Okay I’ll just make it send to the server when they update their preference so that I don’t have this issue.