So , I made a Script to make a Character Bounce and it works fine but i would like it more smooth. Cuase everytime I hit the ground instead of keeping my Speed from a Bounce wall or so i go straight up again.
Example: https://gyazo.com/5022f7db92e364a923435bb75ce5111a
Code:
local Rope = game.Workspace.CharCloneParts.RopeConstraint
local Attachment1 = game.Workspace.CharCloneParts.Attachment1
local Attachment2 = game.Workspace.CharCloneParts.Attachment2
local part = game.Workspace.Ground
local WallL = game.Workspace.WallLeft
local WallR = game.Workspace.WallRight
local touching = false
game.Workspace.Gravity = 196.2
local TS = game:GetService('TweenService')
local Players = game:GetService("Players") -- Players Service
local Tinfo = TweenInfo.new(0.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
true,
0)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
function SpeedUp()
local myValue = char.Humanoid.WalkSpeed
local tween = TS:Create(char.Humanoid,Tinfo,{WalkSpeed = 32})
tween:Play()
end
end)
end)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
Rope.Parent = char.HumanoidRootPart
Attachment1.Parent = char.HumanoidRootPart
Attachment2.Parent = char.HumanoidRootPart
local air = false
while true do
part.Touched:Connect(function(hit)
if air == false then
air = true
game.Workspace.Gravity = 196.2
local bv = Instance.new("BodyVelocity")
bv.Name = "bounce"
bv.Velocity = Vector3.new(0,40,0) --change the y value
bv.MaxForce = bv.MaxForce * 50 --change this
bv.Parent = player.Character.HumanoidRootPart
task.wait(0.1)
bv:Destroy()
air = false
game.Workspace.Gravity = 50
end
end)
wait(0.1)
end
end)
end)
WallL.Touched:Connect(function(hit) -- Left Wall
if touching == false then
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
touching = true
game.Workspace.Gravity = 196.2 --Changes to normal Gravity while Flying Up
local bv = Instance.new("BodyVelocity")
bv.Name = "bounce"
bv.Velocity = Vector3.new(40,0,0) --change the y value
bv.MaxForce = bv.MaxForce * 50 --change this
bv.Parent = player.Character.HumanoidRootPart
task.wait(0.1)
bv:Destroy()
touching = false
game.Workspace.Gravity = 50 --Chnages Back to low gravity since Falling
SpeedUp()
end
end
end)
WallR.Touched:Connect(function(hit) --Right Wall
if touching == false then
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
touching = true
game.Workspace.Gravity = 196.2 --Changes to normal Gravity while Flying Up
local bv = Instance.new("BodyVelocity")
bv.Name = "bounce"
bv.Velocity = Vector3.new(-40,0,0) --change the y value
bv.MaxForce = bv.MaxForce * 50 --change this
bv.Parent = player.Character.HumanoidRootPart
task.wait(0.1)
bv:Destroy()
touching = false
game.Workspace.Gravity = 50 --Chnages Back to low gravity since Falling
SpeedUp()
end
end
end)
How it is and how i would like it to be: