Hi, I am making a car locking system. But there is a bit of a problem.
The issue is I have a car spawning system and if 2 players spawn the same car and 1 of them locks it, the other player is locked out of his car.
Pictures of code:
Since you are using a single RemoteEvent for all the cars and all the cars listen to the same event they will obviously all do the same thing when the player clicks lock thus making other players’ cars locked. You need a better handling for this system which will not use the same event for all the cars or at least pass a reference to the car object to lock so that only a specific car gets locked
For example put an object value inside the LocalScript that fires the event, the ObjectVlue’s value would be the car’s Ownership instance, when firing the event pass the value of the ObjectValue and on the server set that passed instance’s value to the player. Ofcourse do checks to make sure that the player is only able to lock their car (for exploits prevention)