--|| This is the script its erroring at the line after "Found a seat" ||-- local Prompt = script.Parent local ActionText = "Hold F to join the car" local HoldDuration = .8 local MaxActivationDistance = 7.5 Prompt.ActionText = ActionText Prompt.ClickablePrompt = true Prompt.HoldDuration = HoldDuration Prompt.KeyboardKeyCode = Enum.KeyCode.F Prompt.MaxActivationDistance = MaxActivationDistance Prompt.ObjectText = "Join the car" Prompt.RequiresLineOfSight = true local BackSeats = script.Parent.Parent["Back Seats"] Prompt.Triggered:Connect(function(Player) local Character = Player.Character if Character then for _, seat in pairs(BackSeats:GetChildren()) do if seat.Occupant == nil then print("Found a seat") seat.Occupant = Character.Humanoid break end end end end)
Error: Can't set the value
https://developer.roblox.com/en-us/api-reference/property/Seat/Occupant This property can only be read from. Attempting to write to it will cause an error.
Like yx10055 correctly said, you cannot set the seat occupant. Instead replace lines 21-25 with the following code.
if seat.Occupant then return end --Make sure seat is empty if not Character then return end --Check for character local humanoid = Character:FindFirstChild("Humanoid") if not humanoid then return end --Check for humanoid seat:Sit(humanoid) --Player sits if seat is empty, character exists, and humanoid exists