Car locking system issue

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:




I am still learning how to script, any help would be awesome.

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)

1 Like

So, Should I create multiple remote events for each car?

That would not be a good idea if there are going to be lots of cars. Please read my updated reply above as i suggested a way to fix this

How would I do this, It’s a bit advanced for me.

In edit mode

  1. Inside the car model create a LocalScript
  2. Inside the LocalScript (basically the script that will fire the event to lock the car) create an ObjectValue
  3. Set the value to the Ownership instance that is inside the ProximityPrompt

When the game runs

  1. Make a Script detect when someone boards the car and clone the LocalScript to their PlayerScripts or to something where LocalScripts can run
  2. Program the LocalScript to pass the value of the Object value inside of it when firing the event.
  3. Make the server set the value of the passed Ownership instance to the player’s name
1 Like

Sorry to ask this, but what exactly am I putting in this script. I’m still learning how to script.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.