Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SeatOccupant = nil
- function CreateSeat()
- local Part = Instance.new("Part")
- Part.Name = "Seat"
- local localSeatWeld = Instance.new("Weld")
- local LocalTouch = nil
- local WhenJumped = nil
- local SatDebounce = os.clock()
- LocalTouch = game:GetService("RunService").RenderStepped:Connect(function()
- local Character = game:GetService('Players').LocalPlayer.Character
- if Character and Character:FindFirstChildWhichIsA('Humanoid') and Character:FindFirstChildWhichIsA('Humanoid'):GetState()~=Enum.HumanoidStateType.Seated and (Character:FindFirstChild("Torso") or Character:FindFirstChild("UpperTorso")) and os.clock()-SatDebounce >= 2 then
- local Torso = Character:FindFirstChild('Torso') or Character:FindFirstChild("UpperTorso")
- localSeatWeld.C0 = CFrame.new(0,Torso.Size.Y,0)
- local Region = workspace:GetPartBoundsInBox(Part.CFrame,Part.Size,OverlapParams.new({
- ['MaxParts'] = 100
- }))
- local CharacterWillSit = false
- for _,part in pairs(Region)do
- if part and part:IsDescendantOf(Character) then
- Character:FindFirstChildWhichIsA('Humanoid').Sit = true
- SeatOccupant = Part
- CharacterWillSit = true
- break
- end
- end
- if CharacterWillSit then
- if not WhenJumped then
- WhenJumped = Character:FindFirstChildWhichIsA('Humanoid'):GetPropertyChangedSignal('Jump'):Connect(function()
- if Character:FindFirstChildWhichIsA('Humanoid').Jump == true then
- localSeatWeld.Parent = nil
- SatDebounce=os.clock()
- if WhenJumped then
- WhenJumped:Disconnect()
- WhenJumped = nil
- end
- end
- end)
- end
- localSeatWeld.Parent = Part
- localSeatWeld.Part0 = Part
- localSeatWeld.Part1 = Torso
- else
- if WhenJumped then
- WhenJumped:Disconnect()
- WhenJumped = nil
- end
- localSeatWeld.Parent = nil
- end
- end
- end)
- return Part
- end
- local Seat = CreateSeat()
- Seat.Anchored = true
- Seat.Parent = workspace
- Seat.Position = workspace.SpawnLocation.Position + Vector3.new(0,4,0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement