I’m making a stand game, is there any way to improve this code?
local followPlayer2 = false
local standValue2 = false
local quoteEnd2 = false
local kickPlayer2 = false
local timeStopped2 = false
local standOut2 = false
local quoteTable2 = {
}
local rollAnimation2 = Instance.new("Animation")
rollAnimation2.AnimationId = "rbxassetid://5023224010"
local poseEnabled2 = false
game:GetService("UserInputService").InputBegan:Connect(function(input,gameProccessed)
if gameProccessed == false then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.F then
if game.Players.LocalPlayer.standValue.Value == "RigTest" then
local BodyThrust = Instance.new("BodyThrust",game.Players.LocalPlayer.Character.HumanoidRootPart)
BodyThrust.Force = Vector3.new(math.huge,math.huge,math.huge)
end
if game.Players.LocalPlayer.standValue.Value == "Forgotten Memory" then
timeStopped2 = not timeStopped2
if timeStopped2 == true then
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").PunchAnimation:FireServer("Ability")
end
if timeStopped2 == false then
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").PunchAnimation:FireServer("AbilityStop")
end
end
end
if kickPlayer2 == false then
if game.Players.LocalPlayer.standValue.Value ~= "Long story short" then
if input.KeyCode == Enum.KeyCode.R then
kickPlayer2 = true
if kickPlayer2 == true then
followPlayer2 = "Kick"
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").KickAnimation:FireServer("Play")
wait(1)
followPlayer2 = true
wait(1)
kickPlayer2 = false
end
end
end
end
end
if game.Players.LocalPlayer.standValue.Value ~= "Long story short" then
if input.KeyCode == Enum.KeyCode.N then
if quoteEnd2 == false then
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").SayQuote:FireServer(quoteTable2[math.random(1,#quoteTable2)])
quoteEnd2 = true
wait(2)
quoteEnd2 = false
end
end
end
if game.Players.LocalPlayer.standValue.Value ~= "Long story short" then
if input.KeyCode == Enum.KeyCode.E then
followPlayer2 = "Punch"
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").PunchAnimation:FireServer("Play")
end
end
if input.KeyCode == Enum.KeyCode.Q then
if game.Players.LocalPlayer.standValue == "RigTest" then
followPlayer2 = "Other"
end
if game.Players.LocalPlayer.standValue ~= "RigTest" then
followPlayer2 = not followPlayer2
end
game:GetService("RunService").RenderStepped:Connect(function()
if followPlayer2 == true then
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").HumanoidRootPart.Anchored = false
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").HumanoidRootPart.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame * CFrame.new(-2,2,3)
end
if followPlayer2 == false then
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").HumanoidRootPart.CFrame = CFrame.new(-6.5, 63, 53, 1, 0, 0, 0, 1, 0, 0, 0, 1)
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").HumanoidRootPart.Anchored = true
end
if followPlayer2 == "Punch" then
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").HumanoidRootPart.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame * CFrame.new(-0.5,0,-3)
end
if followPlayer2 == "Kick" then
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").HumanoidRootPart.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame * CFrame.new(-0.5,0,-3)
end
if followPlayer2 == "Other" then
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").HumanoidRootPart.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame * CFrame.new(-2,2,3)
end
end)
end
end
end)
game:GetService("UserInputService").InputEnded:Connect(function(input2)
if input2.UserInputType == Enum.UserInputType.Keyboard then
if game.Players.LocalPlayer.standValue.Value ~= "Long story short" then
if input2.KeyCode == Enum.KeyCode.E then
followPlayer2 = true
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").PunchAnimation:FireServer("Stop")
end
end
end
end)
game.Players.LocalPlayer.Chatted:Connect(function(message)
if message:lower() == "become/" then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").Humanoid
end
end)
while true do
wait(3)
game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name.."2").PunchAnimation:FireServer("Float")
end