I wanted to make a bounce Script and wanted to make it more advanced with different outcomes of how he touches the wall and if he Presses anything but now he stops after 1 Wall Jump:
Problem:
https://gyazo.com/bd3ca0ff2add80cf1c6f13806e1730ab
Script Serverside:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InputDirEvent = ReplicatedStorage:WaitForChild("InputDir")
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)
local InputDir = Instance.new("StringValue")
InputDir.Parent = player
InputDir.Name = "InputDir"
InputDir.Value = "None"
local Direct = Instance.new("StringValue")
Direct.Parent = player
Direct.Name = "Direction"
Direct.Value = "Neutral"
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)
local part = game.Workspace.Ground
local WallL = game.Workspace.WallLeft
local WallR = game.Workspace.WallRight
local touching = false
game.Workspace.Gravity = 50
part.Touched:Connect(function(hit)
if touching == false then
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
Direct = player.Direction
InputDir = player.InputDir
if Direct.Value == "Neutral" 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(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()
touching = false
Direct.Value = "Neutral"
game.Workspace.Gravity = 50 --Chnages Back to low gravity since Falling
elseif Direct.Value == "Left" then
if InputDir == "Left" 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,40,0) --change the y value + Left
bv.MaxForce = bv.MaxForce * 50 --change this
bv.Parent = player.Character.HumanoidRootPart
Direct.Value = "Neutral"
task.wait(0.1)
bv:Destroy()
touching = false
game.Workspace.Gravity = 50 --Chnages Back to low gravity since Falling
elseif Direct.Value == "Right"then
if InputDir == "Right" 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,40,0) --change the y value + Right
bv.MaxForce = bv.MaxForce * 50 --change this
bv.Parent = player.Character.HumanoidRootPart
Direct.Value = "Neutral"
task.wait(0.1)
bv:Destroy()
touching = false
game.Workspace.Gravity = 50 --Chnages Back to low gravity since Falling
elseif InputDir.Value == "None" 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(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()
touching = false
Direct.Value = "Neutral"
game.Workspace.Gravity = 50 --Chnages Back to low gravity since Falling
else
end
end
end
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
local Direct = player:FindFirstChild("Direction")
local InputDir = player:FindFirstChild("InputDir")
touching = true
Direct.Value = "Right"
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
local Direct = player:FindFirstChild("Direction")
local InputDir = player:FindFirstChild("InputDir")
touching = true
Direct.Value = "Left"
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)
InputDirEvent.OnServerEvent:Connect(function(plr, Direction)
plr.InputDir.Value = Direction
end)
I also have a Local Script for the Value Chnaage to notice the Direction hes Pressing for Controller Support and co. but i dont think its that relevant only if you think the problems there
Script Local: (Basically Control Script)
local player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InputDir = ReplicatedStorage:WaitForChild("InputDir")
local jumping = false
local leftValue, rightValue = 0, 0
local function onLeft(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
leftValue = 1
InputDir:FireServer("Left")
elseif inputState == Enum.UserInputState.End then
leftValue = 0
InputDir:FireServer("None")
end
end
local function onRight(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
rightValue = 1
InputDir:FireServer("Right")
elseif inputState == Enum.UserInputState.End then
rightValue = 0
InputDir:FireServer("None")
end
end
local function onJump(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
jumping = true
elseif inputState == Enum.UserInputState.End then
jumping = false
end
end
local function onDown(actionName, inputState)
local falling = false
if inputState == Enum.UserInputState.Begin then
if falling == false then
falling = 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(0,-100,0) --change the y value
bv.MaxForce = bv.MaxForce * 500 --change this
bv.Parent = player.Character.HumanoidRootPart
task.wait(0.1)
bv:Destroy()
game.Workspace.Gravity = 50
InputDir:FireServer("None")
elseif inputState == Enum.UserInputState.End then
falling = false
else
end
end
end
local function onUpdate()
if player.Character and player.Character:FindFirstChild("Humanoid") then
if jumping then
player.Character.Humanoid.Jump = true
end
local moveDirection = rightValue - leftValue
player.Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
end
end
RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)
ContextActionService:BindAction("Left", onLeft, true, "a", Enum.KeyCode.Left, Enum.KeyCode.DPadLeft)
ContextActionService:BindAction("Right", onRight, true, "d", Enum.KeyCode.Right, Enum.KeyCode.DPadRight)
ContextActionService:BindAction("Down", onDown, true, "s", Enum.KeyCode.Down, Enum.KeyCode.DPadDown)