Problem with getting character out of seat

What I want to achieve

I have a normal seat, if the player owns a gamepass they will stay seated. If they don’t own the gamepass they will be “kicked” from the seat.

What is the problem

I use Humanoid.Jump = true for this. It works the first time but the second it only prompts and does not kick the player out of the seat.

The script

local gamepassid = 4129623

script.Parent.Changed:Connect(function()
	if script.Parent.Occupant then
		local occupant = script.Parent.Occupant
		if game.Players:GetPlayerFromCharacter(occupant.Parent) then
			local player = game.Players:GetPlayerFromCharacter(occupant.Parent)
			if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,gamepassid) then
				-- do nothing
			else
				occupant.Jump = true
				game:GetService("MarketplaceService"):PromptGamePassPurchase(player,gamepassid)
			end
		end
	end
end)

What I need help with

I need help to figure out what I have done wrong and how to fix the problem

2 Likes

You could also do

if script.Parent:FindFirstChild("SeatWeld") then
    script.Parent.SeatWeld:Destroy()
end

I’m not sure if this is an issue, but I’ve seen other people run into the same issue, I’m pretty sure making the character jump should dismount the character.

Edit:
Another way is to set the Humanoid.Sit to false

Thanks for your input! I tried the piece of code you sent. I still got the same problem, works the first time but not the second. The second time it said the following:
Something unexpectedly tried to set the parent of SeatWeld to NULL while trying to set the parent of SeatWeld. Current parent is Seat.

Oh, you can try adding a wait right after the event is fired.

script.Parent.Changed:Connect(function()
    wait(0.1)
    --code
end
1 Like

I also tried that and the platform stand value, nothing seemed to work sadly.

I will make sure to try that pice of code out.

@applepen77710 Thanks, I did not test that out as this fixed the problem:

@wevetments Thanks for your help!

1 Like