How to make a pull up bar not be able to play a animation when off of a seat

I have this script inside of StarterCharacterScripts and with this script i can play my pull up animation from anywhere. How can i make it so it can play only when you are sitting?
Script:

local UIS = game:GetService("UserInputService")

local player = game.Players.LocalPlayer
local character = player.Character

local seat = game.Workspace.PullUpBar
local pullUpAnim = script:WaitForChild("PullUp")

local isPulling = false
local PullUpEvent = game.ReplicatedStorage:WaitForChild("OnClickPullUp")


UIS.InputBegan:Connect(function(input)

	if input.UserInputType == Enum.UserInputType.MouseButton1 then

		if isPulling == true then return end

		if not character:FindFirstChild("Humanoid") then return end

		isPulling = true

		local loadedAnim = character.Humanoid:LoadAnimation(pullUpAnim)
		loadedAnim:Play()

		PullUpEvent:FireServer()
		wait(2)

		isPulling = false
	end
end)

Id like to know how to fix this, could be simple or could be a bit too difficult for me

1 Like

You can use the Humanoid.Sit property to check if the the player is sitting in a seat or vehicle seat.

I would implement this using this Humanoid.Sit bollean. You could do a check similar to the isPulling check you are already doing.

For example

if isSitting == false then return end

isSitting would theoretically equal humanoid.Sit

Hope this could help.