My game creates some parts on the server side when a player joins the game, which all players can now see (as server replicates them to client)
These parts are owned by the joining player, thats all good.
What i want now is when a player leaves the game, is to remove thier owned parts from server and also all over clients in that server.
Im removing from server but they stay in the clients. Am i missing something obvious or do i need to fire to clients to remove (bit worried to use firetoclient method, due to exploiting).
If the parts are created by the server, calling :Destroy() on all of them should remove them from every body, unless your clients are caching the parts and creating them locally.
im currently doing the playerRemoving method, but they are not removing on clients. And parts are created on the Server side. I will of cause double check now.
Try using FireClient? What exactly are you using these parts for so I can know if they can get exploited or not. Also if it’s when a player leaves, why do you want it to be removed on client if the player isn’t there in the first place?
So basicly, when a player joins it goes to my web API and gets their player data. In that data is a list of “say parts for now”. In the data each part has the playerid (not roblox but still unique) this id is used to flag which part is owned by which player. I hope that makes sense.
to explain as much as i can :). These parts are a sort of marker for owned item within the world, lets say bit like a flag. I want others to see these within the world, so they are loaded to all when a player joins. Im worried that if i call FireClient passing player and removing them as they leave, that someone might exploit and use client side code to remove all. It wont effect any data, but would be very annoying. I could of cause make sure the client side parts always match the server side ones, say on a timed event, but what a pain LOL
Well you can try using obfuscation methods on your :FireClient function to make it slightly more secure. I’d go with that method and see how it works out. If it doesn’t then you can do that timed method. Apart from that I don’t really have any ideas? Try seeing what other people say and if anything I’ll try and think of a proper solution.
As the database is a central one for all possible players ever. You could end up with 1,000s of parts from players that left the server. If say the server takes weeks to close down due to someone always in game.
I’m not really sure how remote events work properly and I’m not on my computer atm to check. But does FireClient also affect others if ran from an exploiters POV?
edit; after doing some research, turns out FireClient doesn’t affect others like that unless manipulated by FireServer or any other server function so try using FireClient
Think for now, your right i will do FireClient method, just so i can move forward. If it gets to be an issue maybe come up with something else. I was just surprised it doesnt auto remove them if destroyed on server. LOL prob missing something simple. Thanks everyone for the comments/ideas. When if solved i will post solution i came up with. Sorry for being vague about in game features but NDA etc etc lol
thanks for that, I am going with that and some extra token stuff the game already uses. So the client code and verify the server called it etc etc. Thanks for taking the time to reply
OMG, so sorry for wasting your time. It worked as expected normally removing from server and replicates to clients automaticly. The problem was and please dont laugh, in my function i had a “return nil” before the removing model code all corrected now and working properly.