So awhile ago i made a post about my seat not sitting the humanoid. It has been fixed, but now my script only functions for one seat, and not my other seats
The video shows my issue
This is my code;
local Seats = script.Parent.Seats
local ProximityPromptService = game:GetService("ProximityPromptService")
for _ , v in ipairs(Seats:GetChildren()) do
Seat = v
SeatPrompt = Seat:FindFirstChild("SeatPrompt")
end
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant ~= nil then
SeatPrompt.Enabled = false
elseif Seat.Occupant == nil then
SeatPrompt.Enabled = true
end
end)
ProximityPromptService.PromptTriggered:Connect(function(SeatPrompt , plr)
local Humanoid = plr.Character:FindFirstChildOfClass("Humanoid")
Seat:Sit(Humanoid)
print("Test")
end)
I think I found the problem when you declare the seat every iteration, it will only be set the one seat. All the following code is only doing it for the last assignment of the variable seat. Try putting the rest of the code inside of the loop, so it knows that every seat should have it.
Hi, again, it does only one variable in the for loop because only the last value counts and ur using ipairs thats why its always the same seat.
Can i see where the prompt is located in the explorer?
After doing some experimenting, I found that creating a new proximity prompt instance when the loop runs solves the problem I’ve been having, thanks everyone for the help and responses