i have been on this for hours now so basically i got this table here with all the seat
local Seats = {
workspace["Model [2] Alpha Series of Main Battery Class"].Seat
--and so on repeat
}
there is only one cuz i want to keep things simple and also it wouldnt change if i put all of my seats in the table
and this for loop loops through the table and see if player is sitting on one of these seats
if player is sitting on one of these seats in the table then it will print ok so i know the script is working but the script does not print ok and didnt error so i dont know whats wrong
for i, Seat in pairs(Seats) do if Seat.Occupant ~= nil then print("ok") -- it just wont work else print("no") end end
im planning to use this to parent a remote event to rep storage when i get these print statements to work
a local script will be waiting to use that same remote event to transfer some important data that most likely is needed to parent the remote event back to server storage
i found answer myself
edit: after a bit of testing and more research i found something that will work and is less complex
local Seats = { workspace["Model [2] Alpha Series of Main Battery Class "].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 RemoteEvent = game.ServerStorage.RemoteEvent Seat.Changed:Connect(function(Properties) if Seat.Occupant ~= nil then RemoteEvent.Parent = game.ReplicatedStorage elseif Properties == "Occupant" and Seat.Occupant == nil then RemoteEvent.Parent = game.ServerStorage end end) end
I’m sorry that this comment has nothing to do with this section, but I have been trying to post a question: “Why won’t my if statement run”, but it says “your question could not be posted because the title is too long”. I even changed the title to “if statement” and it still would not work!