Trying to make players jumppower to 0 when they sit on a chair

when the player sits on one of the seats from the table, if the seat is from the table then i want the players jump power to be set to 0. not sure how to check if its from the table tho. tysm!

local seats = game.workspace.seats

-- Table to hold the chair variables, and if they're taken or not
local seatStatus = {
	{chair = seats.seat1, taken = false},
	{chair = seats.seat2, taken = false},
	{chair = seats.seat3, taken = false},
	{chair = seats.seat4, taken = false},
	{chair = seats.seat5, taken = false},
	{chair = seats.seat6, taken = false},
	{chair = seats.seat7, taken = false},
	{chair = seats.seat8, taken = false},
	{chair = seats.seat9, taken = false},
	{chair = seats.seat10, taken = false},
}

function seatPlrs(plr:Player)
	local char = plr.Character or plr.CharacterAdded:Wait()
	local hum:Humanoid = char:FindFirstChildOfClass("Humanoid")
	local hrp = char:WaitForChild("HumanoidRootPart")

	hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

if hum then

for i, seat in pairs(seatStatus) do
			if seat.taken == false then

seat.chair:Sit(hum)
seat.taken = true
break
			else
				end
end
-- trying to set jumppower to 0 when they sit on a chair from the table seatStatus
hum.Seated:Connect(function(active, currentseat)
	if active and currentseat[seatStatus.chair] then
		hum.JumpPower = 0
	end
end)
end
end

game.Players.PlayerAdded:Connect(seatPlrs)

Try setting the jump power here

for i, seat in pairs(seatStatus) do
	if seat.taken == false then
		seat.chair:Sit(hum)
		hum.JumpPower = 0 -- new line added to your current script
		seat.taken = true
		break
	else
	end
end

This is setting up an event for when the humanoid sits the next time, which is probably why its not working when you initially go to sit down.

2 Likes

hey tyler, i got it. tysm 4 ur response! i changed the jumppower to 0 but it didnt make a difference so i put in jumpheight = 0 and it worked. do u know how to check if the seat came from the table and if so, set the jump power/height to 0? :slight_smile:

script:

local seats = game.workspace.seats

-- Table to hold the chair variables, and if they're taken or not
local seatStatus = {
	{chair = seats.seat1, taken = false},
	{chair = seats.seat2, taken = false},
	{chair = seats.seat3, taken = false},
	{chair = seats.seat4, taken = false},
	{chair = seats.seat5, taken = false},
	{chair = seats.seat6, taken = false},
	{chair = seats.seat7, taken = false},
	{chair = seats.seat8, taken = false},
	{chair = seats.seat9, taken = false},
	{chair = seats.seat10, taken = false},
}

function seatPlrs(plr:Player)
	local char = plr.Character or plr.CharacterAdded:Wait()
	local hum:Humanoid = char:FindFirstChildOfClass("Humanoid")
	local hrp = char:WaitForChild("HumanoidRootPart")

	hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

if hum then

for i, seat in pairs(seatStatus) do
			if seat.taken == false then
seat.chair:Sit(hum)
seat.taken = true

if seat.chair.Occupant then
				hum.JumpHeight = 0
				hum.JumpPower = 0
				end


break
			else
			end	
			end
end
end

game.Players.PlayerAdded:Connect(seatPlrs)

Ok! Well if you still want to use JumpPower, ensure you have “CharacterUseJumpPower” enabled under the StarterPlayer Service properties, in the explorer.

I’m not quite sure what you are asking here, as by the script, its implied that they would automatically be seated in a seat from the table already. Are you asking for a way to disable jump power/height only when they are in 1 of the 10 seats in the table, otherwise don’t set the jump power/height?

2 Likes

Blockquote
Ok! Well if you still want to use JumpPower, ensure you have “CharacterUseJumpPower” enabled under the StarterPlayer Service properties, in the explorer.

i will. what does it do actually? i read up about it in the documentation but i have no clue.

Blockquote I’m not quite sure what you are asking here, as by the script, its implied that they would automatically be seated in a seat from the table already. Are you asking for a way to disable jump power/height only when they are in 1 of the 10 seats in the table, otherwise don’t set the jump power/height?

my apologies, i was trying to say if the seat is not from the table then have the function not run. like if theres other seats in the workspace then it wouldnt work for them. :slight_smile:

JumpPower is affected by gravity, whereas JumpHeight is not.

Based on the current code you have, whenever a player connects to the game, they will be seated at 1 one of the 10 seats. They will not be able to jump out of the seat either. Based on that, this should only work once(when the player connects) and next time they sit down on any seat, including 1 of those 10 seats, they will be able to jump out of the seat(also under the assumption you reset their jumppower to like 50).

1 Like

yes. ur dead right. tysm 4 ur help tyler! :slight_smile: