Hello! So basically, I have a script which I’m part referencing from a youtube video but adapting for my own needs and what it does it locks/unlocks a seat. The current way I’m doing this is by setting disbled to true
or false
however, when I am sat in the seat and then disable it, my character can then no longer sit in any seat.
Any help is appreciated
-- My script (Local Script)
local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Local = Players.LocalPlayer
local Char = Players.LocalPlayer.Character
local Input = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
local MaxDistance = 20
for i, v in pairs(game.Workspace.Vehicles:GetChildren()) do
if (v.VehicleSeat.Position - Char.HumanoidRootPart.Position).magnitude < MaxDistance and v.VehicleSeat.Occupant == nil then
LocalNearSeat = v.VehicleSeat
if v.VehicleSeat.Disabled == false then
Local.PlayerGui.LToLock.Adornee = v.VehicleSeat
Local.PlayerGui.LToUnlock.Adornee = nil
Local.PlayerGui.Locked.Adornee = nil
elseif v.VehicleSeat.Disabled == true then
Local.PlayerGui.LToUnlock.Adornee = v.VehicleSeat
Local.PlayerGui.LToLock.Adornee = nil
Local.PlayerGui.Locked.Adornee = nil
end
end
end
end)
Input.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.L then
if LocalNearSeat.Disabled == false then
LocalNearSeat.Disabled = true
elseif LocalNearSeat.Disabled == true then
LocalNearSeat.Disabled = false
end
end
end)