Hello, I'm a beginner scripter and I'm stuck on making this sofa.
local Seat1 = game.Workspace.Seat1
local Seat2 = game.Workspace.Seat2
local Seat3 = game.Workspace.Seat3
Seat1 and Seat2 and Seat3.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("HumanoidRootPart") then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(0, 0.5, -14) end
end)
local Seat1 = workspace.Seat1 local Seat2 = workspace.Seat2 local Seat3 = workspace.Seat3 local playersSeated do playersSeated=Instance.new("BindableEvent",script) local players,debounce={},false local function update(v,add) local char=v.Part1.Parent if add then players[#players+1]=char else table.remove(players,table.find(players,char)) end if #players==3 and not debounce then debounce=true local players=table.clone(players) for i,char in ipairs(players)do if i==#players then debounce=false end local hum=char:FindFirstChildOfClass"Humanoid" if not hum then continue end hum.Jump=false wait() hum.Jump=true wait(.1) local msg,v=pcall(playersSeated.Fire,playersSeated,hum) if not v then warn(msg) end end end end for _,v in ipairs{Seat1,Seat2,Seat3}do v.Anchored=true v.ChildAdded:Connect(function(v)update(v,true)end) v.ChildRemoved:Connect(update) end end; playersSeated.Event:Connect(function(hit) if hit and hit.Parent:FindFirstChild("HumanoidRootPart") then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(0, 0.5, -14) end end)
There is a property inside of a 'Seat' that is called 'Occupied' basically use if statements to check if the property is 'occupied' == true then you can copy a bit of code from TeleportService YT Videos :)