im trying to make shift lock not able to be turned on when player is seated because its binding over my code and i want shift lock to be able to be turned on when player is unseated
code
local Seats = { workspace["Model [2] Alpha Series of Class: Paired Dual Main Battery Station"].Seat, workspace["Model [2] Bravo Series of Main Battery Class "].Seat, workspace["Model [3] Charlie Series of Main Battery Class "].Seat } for i, Seat in pairs(Seats) do local RemoteEvents = game.ServerStorage["Begin[N]End"] local ReplicatedStorage = game:GetService("ReplicatedStorage") local ServerStorage = game:GetService("ServerStorage") local SeatProperty = Seat.Occupant Seat.Changed:Connect(function(Properties) local function OnSEAT(Player) if SeatProperty ~= nil then RemoteEvents.Parent = ReplicatedStorage Player.DevEnableMouseLock = false elseif Properties == "Occupant" and SeatProperty == nil then RemoteEvents.Parent = ServerStorage Player.DevEnableMouseLock = true end end OnSEAT() end) end
You did not define a player with the OnSEAT() function. You just did OnSEAT() without any porperties.
local plr = game.Players.LocalPlayer local Seats = { workspace["Model [2] Alpha Series of Class: Paired Dual Main Battery Station"].Seat, workspace["Model [2] Bravo Series of Main Battery Class "].Seat, workspace["Model [3] Charlie Series of Main Battery Class "].Seat } for i, Seat in pairs(Seats) do local RemoteEvents = game.ServerStorage["Begin[N]End"] local ReplicatedStorage = game:GetService("ReplicatedStorage") local ServerStorage = game:GetService("ServerStorage") local SeatProperty = Seat.Occupant Seat.Changed:Connect(function(Properties) local function OnSEAT(Player) if SeatProperty ~= nil then RemoteEvents.Parent = ReplicatedStorage Player.DevEnableMouseLock = false elseif Properties == "Occupant" and SeatProperty == nil then RemoteEvents.Parent = ServerStorage Player.DevEnableMouseLock = true end end OnSEAT(plr) end) end
I'm assuming it's in a LocalScript.
problem fixed
--local Seats = -- { -- workspace["Model [A]"].Seat, -- workspace["Model [B]"].Seat, -- workspace["Model [C]"].Seat, -- workspace["Model [X]"].Seat, -- workspace["Model [Y]"].Seat -- } --local PlayersService = game:GetService("Players") --PlayersService.PlayerAdded:Connect(function(Player) -- for index, Seat in pairs(Seats) do -- Seat.Changed:Connect(function(Property) -- if Seat.Occupant ~= nil then -- Player.DevEnableMouseLock = false -- elseif Seat.Occupant == nil and Property == "Occupant" then -- Player.DevEnableMouseLock = true -- end -- end) -- end --end)