seat:Sit() problems

My Sit script is making the player sit and be locked into the seat, however, the :Sit() function is not making the player teleport to the seat… The player just goes into the seat animation.

The two events are being fired from a localscript that fires the event when a button is pressed.


 --script by pom

local rep = game.ReplicatedStorage
local sit = rep.TemporarySitEvent
local unsit = rep.Unsit
local seat = game.Workspace.SpecialSeat

sit.OnServerEvent:Connect(function(client) -- client is the player object
	local char = client.Character
	if char then -- check if the client has a character loaded
		local hum = char:WaitForChild("Humanoid")
		
		seat:Sit(hum)
		char:WaitForChild("HumanoidRootPart").Anchored = true
	end
end)
unsit.OnServerEvent:Connect(function(client)
	local char = client.Character
	if char then -- check if the client has a character loaded
		local hum = char:WaitForChild("Humanoid")

		seat:WaitForChild("SeatWeld"):Destroy()
		char:WaitForChild("HumanoidRootPart").Anchored = false
	end
end)

Video:
robloxapp-20220728-1102181.wmv (3.1 MB)

(in the video I keep circling the seat with my mouse)

1 Like

Humanoid.Sit.

I cant actually look at the video, but im assumin that you didn’t “attach” the humanoid to the seat (i dunno how to do that, but i think the above article should help)

seat:Sit() can’t be called from a localscript

Seat:Sit(humanoid) should do everything for me. Ex. make a seatweld and put the player in the seat.

This is all on a server script.

Can you send the video except in a .mp4 format?

Yep, here it is.

You need to CFrame the character to the brick if you want it to sit in the brick I think…

The brick is a ClassName of Seat. The :Sit() function should teleport the player towards the seat and do everything for me. An old Script I had was pretty much the same except it was directly parented to the seat and didn’t have anything to do with remote events. My new script is in ServerScriptService.

Here is the old script:

--THIS IS A TEST SCRIPT - pom
--scripted by pom




local seat = script.Parent

game.Players.PlayerAdded:Connect(function(plr)
	
	plr.CharacterAdded:Connect(function(char) --detect when the character is added and also get it
		wait(3)
		seat:Sit(char:WaitForChild("Humanoid"))
		
		local rootpart = char:WaitForChild("HumanoidRootPart")
		wait(1)
		rootpart.Anchored = true
		
	end)
	
end)

The old script worked before. But I don’t know why this new script isn’t working…

Make sure the seat isn’t disabled

Nope! It’s all good:

allgood

you are referencing the seat correctly too right

You can manually create a SeatWeld, which is just a weld from the seat to the root of the character, parented to the seat.

Actually, try putting a wait command before you anchor the humanoid root part.

1 Like
if char then -- check if the client has a character loaded
		local hum = char:WaitForChild("Humanoid")
		seat:Sit(hum)
        wait()
		char:WaitForChild("HumanoidRootPart").Anchored = true
	end

What’s most likely happening is that the humanoidrootpart is anchoring before the player gets teleported to the seat

Sorry everybody, I was at lunch, I will try to see if one of the methods you guys suggested works. Thank you!