Animation Glitching

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

    I want my animation to stop glitching

  2. What is the issue? Include screenshots / videos if possible!

    My animation is glitching ( It appears to play two animations instead of overriding the original animation )

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

    I have tried setting the animation priority to action4, but still doesn’t work. I do look for solutions but I think it’s unrelated.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- When sitting:
	DrivingTrack:Play()
	DrivingTrack.Looped = true
-- When not sitting:
	DrivingTrack:Stop()
	DrivingTrack = nil

I don’t want people to know my full script so I just put these.

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Note that I make this as simple as possible so people could give me a solution.

1 Like

I think I’ve found the solution. You see, I load the animation with animator, not humanoid (The devforum told us developers to use animator). So I tried using humanoid (and not animator) and it worked. I don’t know if this is a yay or uhh.

1 Like

Add global instances as your debounce.

if sitting then
   sit = true
  --Animation play
else
   sit = false
end
1 Like

Nice idea but you didn’t know how the script worked.

game.ContextActionService:BindAction("EnterCar", function(n, istate, iobject)
	

	local DrivingAnimation = script.DriverSeat

	local DrivingTrack = humanoid:LoadAnimation(DrivingAnimation)
	
	if istate== Enum.UserInputState.Begin then
		if humanoid.SeatPart then
			local carModel = humanoid.SeatPart:FindFirstAncestorOfClass("Model")
			humanoid.Sit = false
			DrivingTrack:Stop()
			DrivingTrack = nil
			enableJumpButton()

			--humanoid.Parent.HumanoidRootPart.CFrame = humanoid.SeatPart.CFrame:ToWorldSpace(CFrame.new(-5, 0, 1))
		else
			local nearestcar,nearestdist = nil, 10
			
			for i, v in pairs(workspace.Vehicles:GetChildren()) do
				local dist = (v.PrimaryPart.Position - char.HumanoidRootPart.Position).magnitude
				if dist < nearestdist then
					nearestcar = v
					nearestdist = dist
				end
			end
			if nearestcar then
				local entirePrimCFrame = nearestcar.PrimaryPart.CFrame
				local carRotations = CFrame.lookAt(Vector3.zero, entirePrimCFrame.LookVector, entirePrimCFrame.UpVector)
				
				game.ReplicatedStorage.AskForDoor:FireServer()
				wait(0.2)
				local nearestseat
				for i, v in pairs(nearestcar:GetChildren()) do
					if (v:IsA("VehicleSeat") or v:IsA("Seat")) and not v.Occupant then
						local dist = (v.Position - char.HumanoidRootPart.Position).magnitude
						if dist < nearestdist then
							nearestseat = v
							nearestdist = dist
						end
					end
				end
				if nearestseat then
					local currentCFrame = char.HumanoidRootPart.CFrame
					nearestseat:Sit(humanoid)
					DrivingTrack:Play()
					DrivingTrack.Looped = true
					local seatWeld = nearestseat:WaitForChild("SeatWeld")
					disableJumpButton()
					
					if seatWeld then
						local oldC0 = seatWeld.C0 + nearestseat.CFrame:ToWorldSpace(CFrame.new(-6, 1.5, -2))
						local oldC1 = seatWeld.C1
						seatWeld.C0 = nearestseat.CFrame:ToObjectSpace(currentCFrame)
						seatWeld.C1 = CFrame.new()
						game.TweenService:Create(seatWeld, TweenInfo.new(0.35),{
							C1 = oldC1,C0 = oldC0}):Play()
						wait(0.2)
					end
				end
			end
			
		end
	end
end, false, Enum.KeyCode.E)

image

Bro, jokes aside. I really didn’t want to put my full script because sometimes people would just steal scripts. But to make you understand the scripts, I decided to put the entering car script.
And I have only 1 solution that is to use humanoid. only 1 :skull:

image

Like I said, I want you to understand the script so I reveal the script and you just keep highlighting something that’s useless and unrelated to our chat.

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