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)
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.
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
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.
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 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