I’ve been coding up a little platformer physics script. Here’s what I have so far:
local Character = script.Parent
Character.Archivable = true
local Anim = nil
local Humanoid:Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid")
local DoubleJump = true
local IsJumping = false
local IsPounding = true
local IsRolling = true
local HasRolled = false
local StopRolling = false
game.UserInputService.JumpRequest:Connect(function()
if Humanoid.FloorMaterial == Enum.Material.Air and DoubleJump == true and IsJumping == false then
DoubleJump = false
if Anim then
Anim:Stop()
end
Anim = Humanoid:LoadAnimation(script.djump)
Anim:Play()
Humanoid.RootPart.Velocity += Vector3.new(0, 50, 0) + Humanoid.RootPart.CFrame.LookVector * 15
print("Boioioing")
for i, obj in pairs(Character:GetDescendants()) do
obj.Archivable = true
end
local Clone = Character:Clone()
Clone.Parent = workspace
for i, obj in pairs(Clone:GetDescendants()) do
if obj:IsA("Part") or obj:IsA("MeshPart") then
obj.Color = Color3.fromRGB(255, 255, 255)
obj.CanCollide = false
obj.Anchored = true
obj.Transparency = 0.5
obj.Material = Enum.Material.Neon
game.TweenService:Create(obj, TweenInfo.new(1, Enum.EasingStyle.Linear), {["Transparency"] = 1}):Play()
elseif not obj:IsA("SpecialMesh") then
obj:Destroy()
end
end
wait(0.5)
Anim:Stop()
wait(0.5)
Clone:Destroy()
end
end)
game.UserInputService.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.LeftShift then
StopRolling = true
end
end)
game.UserInputService.InputBegan:Connect(function(Input, GameProcessed)
if GameProcessed == false and Input.KeyCode == Enum.KeyCode.LeftShift and IsPounding == true then
IsPounding = false
if Anim then
Anim:Stop()
end
Anim = Humanoid:LoadAnimation(script.gpound)
Anim:Play()
repeat wait()
Humanoid.RootPart.Velocity += Vector3.new(0, -10, 0)
until Humanoid.FloorMaterial ~= Enum.Material.Air
Anim:Stop()
elseif GameProcessed == false and Input.KeyCode == Enum.KeyCode.LeftShift and IsRolling == true and HasRolled == false then
IsRolling = false
HasRolled = true
if Anim then
Anim:Stop()
end
Anim = Humanoid:LoadAnimation(script.nroll)
Anim:Play()
Humanoid.WalkSpeed = 1
repeat Humanoid.RootPart.Velocity = Humanoid.RootPart.CFrame.LookVector * 75
wait()
until StopRolling == true or IsJumping == true
Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
StopRolling = false
Anim:Stop()
HasRolled = false
end
end)
while wait() do
if Humanoid.FloorMaterial ~= Enum.Material.Air then
DoubleJump = false
IsPounding = false
IsRolling = true
IsJumping = false
else
DoubleJump = true
IsPounding = true
IsRolling = false
IsJumping = true
end
end
The problem is, whenever I ground pound, I just can’t roll at any point afterwards.
example:
How can I fix this?