Trying to get a Bounch Effect on Character

Note: I removed the Basic Movement so you can only move left or right no jumping or so.

Error 1: It looks Glitched (Not Smooth)
Error 2: I cant move in the Air (Ik Anchored but I need an alternative)
Error 3: The First Time is completly different

So I wanted the Character to bounche like a Bouncy ball so i thought "Hmmm , maybe I could use TweeningService " and then I made this.

local part = game.Workspace.Ground
local touching = false


while wait(0.1) do
	part.Touched:Connect(function(hit)
		if touching == false then
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		if player then
			
				touching = true
				local Character = player.Character
				local plrname = player.Name
				local partTween = game.Workspace:WaitForChild(plrname).HumanoidRootPart
				local TweenService = game:GetService("TweenService")
				local Position = partTween.Position

				local info = TweenInfo.new(
					1, -- Time animating
					Enum.EasingStyle.Quart, -- EasingStyle
					Enum.EasingDirection.Out, -- EasingDirection
					0, -- Repitions
					false, -- Reverse post tween?
					0 -- Delay time
				)
				print("Tween1")

				local goal = {

					-- HERE
					Position = partTween.Position + Vector3.new(0, 20, 0) -- adds plus 20 Y to the old position

				}
				
				for _, object in ipairs(Character:GetChildren())  do
					if object:IsA("Part" or "MeshPart") then
						object.Anchored = true
					end
				end
				
				TweenService:Create(partTween, info, goal):Play()
				wait(1)
			for _, object in ipairs(Character:GetChildren())  do
					if object:IsA("Part" or "MeshPart") then
						object.Anchored = false 		
				end
				end
				touching = false
				print("Tween2")

			end
		end
		end)
	end

https://gyazo.com/c7dbed5768ea952d36239c8484228302

1 Like

first thing you need to remove the while loop

I would use a body velocity.

part.Touched:Connect(function(hit)
	if touching == false then
		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		
		if player then
			touching = true
			local bv = Instance.new("BodyVelocity")
			bv.Name = "bounce"
			bv.Velocity = Vector3.new(0,50,0) --change the y value
			bv.MaxForce = 30 --change this
			bv.Parent = player.Character.HumanoidRootPart
			task.wait()
			bv:Destroy()
			touching = false
		end
	end
end)

Edit: not completely sure if this would work, but I believe it will.

1 Like

ye i think that would solve the issue and he need to use BodyPosition rather then BasePart.Anchored

image

whoops

part.Touched:Connect(function(hit)
	if touching == false then
		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		
		if player then
			touching = true
			local bv = Instance.new("BodyVelocity")
			bv.Name = "bounce"
			bv.Velocity = Vector3.new(0,50,0) --change the y value
			bv.MaxForce = bv.MaxForce * 30 --change this
			bv.Parent = player.Character.HumanoidRootPart
			task.wait()
			bv:Destroy()
			touching = false
		end
	end
end)

Nothing happens at all.

https://gyazo.com/e296e5c8a40f2d3f830332900f82b8fa

Change the task.wait() to a task.wait(1)

part.Touched:Connect(function(hit)
	if touching == false then
		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		
		if player then
			touching = true
			local bv = Instance.new("BodyVelocity")
			bv.Name = "bounce"
			bv.Velocity = Vector3.new(0,50,0) --change the y value
			bv.MaxForce = bv.MaxForce * 30 --change this
			bv.Parent = player.Character.HumanoidRootPart
			task.wait(1)
			bv:Destroy()
			touching = false
		end
	end
end)
1 Like

Thx , works now but can i use an EasingStyle to make it more dragged ?

I’m not sure what you mean by dragged. Also, I don’t know if I can.

For Example the easing Sttyle i used was Quint but this would be kind of linear since it always has the same movement and istn fasten up at somepoint or slowed down

I’m honestly not sure, I don’t work with body velocities much, but you would probably need to mess with the maxForce and make it above 50.