Seat instance gets broken when the person sitting gets cframe changed

Hi, im have a combat system that when the enemy gets punched, their cframe will look at u and plays animation of getting hit, but when they are sitting on a seat, the seat cframe gets broken, i tried putting “Humanoid.Sit = false” to the enemy before changing their cframe but the seat still gets broken, is there any reason why? and how to fix it?

i may be gone for quite some time so il just leave the function script here if u guys need, thank you.

Hi, just wondering, what exactly do you mean by “seat gets broken”? It disappears?

I think the problem is that when the player get teleport ( or idk ), it will also teleport the seat.

the cframe of the seat gets broken, what i mean is that the position and orientation changes as if they were attached to the enemy that got knockbacked, even tho i already unseated them before changing their cframe

1 Like

but i already unseat the player before changing cframes

Tbh I have the exact same problem as you before. To simply fix this :
I am assuming you’re using a LocalScript

-- LocalScript
RemoteEvent:FireServer()

-- ServerScript
RemoteEvent.OnServerEvent:Connect(function(plr)
	if plr ~= nil and plr.Character ~= nil then
		local Character = plr.Character
		
		if Character:FindFirstChild("Humanoid").SeatPart ~= nil then
			Character:FindFirstChild("Humanoid").SeatPart:Destroy()
		end
	end
end)

Note : I made this from memory lol

none of the scripts im using is local script, the combat tool is using script firing bindable event to the serverscript to make the hurtbox in front of the character then the getpartsboundinbox-something and collects everyone that have humanoid in it excluding the character giving the punch, then unseat every character that got punched then changed their cframes, but even tho i already unseat them, the seat still follows the character new cframe as if they were still welded before the cframe changes happens, i even put prints to see if the humanoid.sit is really false before the cframe changes, and it is in fact false

Why are you using BindableEvent instead of RemoteEvent?

because the tool is using normal script, not local script, the tool uses Tool.Activated:Connect(function() end) to get signal from player activating the tool

Oh okay, is the hitbox has touched event or something like that? If then :

-- Tool's script or whatever
local HittedPlayer

hitbox.Touched:Connect(function(hitted)
	if game.Players:GetPlayerFromCharacter(hitted.Parent) ~= nil then
		HittedPlayer = game.Players:GetPlayerFromCharacter(hitted.Parent)
	end
end)

-- Fire it I guess?
BindableEvent:Fire(HittedPlayer)

-- Another script
BindableEvent.Event:Connect(function(plr)
	if plr ~= nil and plr.Character ~= nil then
		local Character = plr.Character
		
		if Character:FindFirstChild("Humanoid").SeatPart ~= nil then
			local Seat = Character:FindFirstChild("Humanoid").SeatPart
			Seat:FindFirstChild("SeatWeld"):Destroy()
		end
	end
end)

Also I forgot to read my code twice, turn out the second code make the SeatPart that the player is sitting on get deleted

Edit : this supposed to be :

game.Players:GetPlayerFromCharacter(hitted.Parent)

not this :

game:Players:GetPlayerFromCharacter(hitted.Parent)

It’s probably because I am too used on using game:GetService(“Players”) lol

3 Likes

I see. Those seats are the roblox instance Seat?
That has a Weld inside the Seat part, which is attached to the HumanoidRootPart, you need to change the Sit property of the Humanoid and Destroy the Weld or remove the reference to the HumanoidRootPart of your NPC to correctly “unSeat” it

1 Like

this is interresting, can you give example how to do it?

i didnt know Humanoid.SeatPart existed, il give it a try when i arrived to check it

@BirdieGoodMan already did, I didnt notice cause I was typing at the same time xD
Check Birdie’s example, just instead of finding that name “SeatWeld”, would be better to find the class “Weld”

1 Like

yes he gave the Humanoid.SeatPart ~= nil, which i never knew existed, it will be very helpful if its that easy to identify the part the humanoid is seated at

Yeah, Humanoid holds a reference of the Seat being used.
So you can find easily the Seat and the Weld that the NPC is using.
Humanoid.SeatPart:FindFirstChildWhichIsA("Weld")
And then destroy it

2 Likes

it works exactly how i want it to be, i appreciate both of u for the efforts to help me

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.