How do I reach the seat?

I’m working on a game where I want seat animations to be a big part of, but the problem is that you need to touch the seat to play the animation. If I want to reach the seat comfortable, then the animation will make the player float, but if I want the animation to look clean then the seat needs to be positioned so that the seat is inside another part, somewhere unreachable.

This is what I want:

This is what a have:

Also keep in mind that the first photo of what I want, that isn’t the actual seat and is simply a black part to mimic that of a part. I don’t know what to do, because moving and resizing the seat part doesn’t work, and I’ve tried moving the rig around in the animator but I don’t know what to do. I think the problem might be that it’s focusing on the whole player but I want it to focus on the torso mainly. I’m probably wrong on that but I just don’t know nothing about that, I am more of a builder than a animator or scripter.

3 Likes

Did you accidentally upload the same screenshot?

2 Likes

I’ve updated the pictures, so do you have a solution now?

1 Like

Whats the issue? do you mean other animations makes u unable to reach the seats or something???

You could make it edit the SeatWeld’s C0 with a script like this (This will move your avatar slightly foward)

local Seat = script.Parent
local Offset = 5

Seat.ChildAdded:Connect(function(Child)
	if Child:IsA("Weld") then
		Child.C0 -= Vector3.new(0,0,Offset)
	end
end)
2 Likes

If I make it so you can reach the seat, it will make the player float when playing the animation. But I don’t want the player to float during the animation, so I have to move the seat down so the animation looks clean, meaning the seat can’t be reached.

1 Like

Why do I want my avatar go forward, it looks fine? The problem is that what I have, makes it so I can’t reach the seat, but if I want to be able to reach the seat, the animation will make the player float.

1 Like

Also I think this is something to do in the animation, not the code. I also I don’t want to add more hassle and struggle and I simply just need a change in the animation so that avatar is closer to the seat.

im pretty sure that code actually moves your avatar higher when you sit on the seat, or if it doesn’t, replace offset with 0 and the middle 0 with offset

1 Like

when the player touches the part make their humanoidrootpart teleport cframe to the seat and disable walk by anchoring the humanoid root part and detect if the player jumps, if they jump release the script.

1 Like

I think your right but I think the offset should be a negative number if I want it to be closer to the seat, right? So that the player goes lower on the y-axis therefore closer to the seat.

I want to add this and change it a bit so that it’ll fit my liking, but where do I put it in this script?

seat = script.Parent
function added(child)
	if (child.className=="Weld") then
		human = child.part1.Parent:FindFirstChild("Humanoid")
		if human ~= nil then
			anim = human:LoadAnimation(seat.sitanim)
			anim:Play()
		end
	end
end

function removed(child2)
	if anim ~= nil then
		anim:Stop()
		anim:Remove()
	end
end

seat.ChildAdded:connect(added)
seat.ChildRemoved:connect(removed)

as a child of the seat (as evident by “seat = script.parent”)

I’m gonna be honest, I don’t know what this means, I just know this most basic knowledge of LuaU and I don’t understand what you mean by that.

put it in the seat

the child of an object is basically anything that is “inside” the object in the explorer. Same with parent, its just whatever something is inside of

Okay, I’ve applied the script and it seems to work, thanks for the explanation!

1 Like

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