Lock system problem

So, that’s a lock system. It works for both lock and unlock and it’s also owner only. When i join the car and I press the button to lock it locks. But when I leave from the sit,

4 Likes

Would you mind showing the script that fires the lock and unlock events?

(BTW, you can add ``` before and after your code and it will automatically format it and make it a lot easier to read!)

This is the server sided module for handling this vehicles seating requests

local Workspace = game:GetService("Workspace")
local HttpService = game:GetService("HttpService")

local DOOR_OPEN_SPEED = 2.15
local DOOR_OPEN_ANGLE = 55
local DOOR_OPEN_TIME = 0.5 --How long the door stays open for when entering/leaving

local MAX_SEATING_DISTANCE = 15
local MIN_FLIP_ANGLE = 70 --degrees from vertical

local PackagedScripts = script.Parent
local PackagedVehicle = PackagedScripts.Parent

local RemotesFolder = nil --Set later in the code by the SetRemotesFolder function
	
--Variables
local SeatInteractionCount = {}

local VehicleSeating = {}

local function getVehicleObject()
	return script.Parent.Parent
end

local function carjackingEnabled(obj)
	return obj:GetAttribute("AllowCarjacking")
end

local function getEffectsFolderFromSeat(seat)
	local parent = seat.Parent
	if parent:IsA("Model") then
		if parent:FindFirstChild("Effects") then
			return parent.Effects
		else
			return getEffectsFolderFromSeat(parent)
		end
	end
	return nil
end

local function playDoorSound(seat, sound)
	local sound = seat:FindFirstChild(sound.."Door")
	if sound then
		sound:Play()
	end
end

--Tell if a seat is flipped
local function isFlipped(Seat)
	local UpVector = Seat.CFrame.upVector
	local Angle = math.deg(math.acos(UpVector:Dot(Vector3.new(0, 1, 0))))
	return Angle >= MIN_FLIP_ANGLE
end

local function Raycast(startPos, direction, range, ignore, inceptNumber)
	if inceptNumber == nil then inceptNumber = 0 end
	inceptNumber = inceptNumber + 1
	local ray = Ray.new(startPos, direction * range)
	local part, position = Workspace:FindPartOnRayWithIgnoreList(ray, ignore)
	if part then
		if part.CanCollide == false and inceptNumber <= 5 then
			--raycast again if we hit a cancollide false brick, put a limit on to prevent an infinite loop
			local rangeLeft = range - (startPos - position).magnitude
			part, position = Raycast(position, direction, rangeLeft, ignore, inceptNumber) --Raycast remaining distance.
		end
	end
	return part, position
end
2 Likes

And that’s the other one.


script.Parent.MouseButton1Click:
1 Like

This one is what you wanted to see.

Go i have there Copy script this now is

How does the script above contribute to this post?
It doesn’t.

1 Like

Hmm because script much get error people about

What is that script? I want to fix the car lock and unlock. When I join in the car and I lock it when i leave the sit that I was sitting is opened, so i can sit and the others are not.

I know now about forgot ask that

Are you serious??
I cannot tell if you’re just being a typical internet troller or serious about this…

You provided a script that creates some sort of UI which in no way progresses towards the answer/solution to this post…

1 Like

Do you know the solution to my problem?

What is i dont problem car for

Then what is your objective behind pointless blabbering?

This is quite a slap to your own face you know…

Can someone help with this? That I say here?

Is there any code that involves the seat?

Are you sure there’s not a function that manually changes the Prompt once a player leaves the seat?

I have sent the script that you want, it’s above.

Just to make sure we are on the same page.
When you sit down in a car seat that I will assume to be the driver’s seat; when you lock the car while in the seat and get out the prompt in the seat you were sitting at is still enabled?

The script(s) you have provided above should not influence only one seat but all, so I believe there’s another script changing the Enabled properties of the seat.

Can you please validate there is no other script that may be causing this issue?

Actually, when I am sitting there and I press the button to lock, it locks but when I leave from the sit the driver’s seat enables so I can sit there but not in the other seats.

No there’s no other script. About that. And the lock and unlock is for all the seats, but i am trying to find a solution to what i have told you above.