Im trying to make a GroundPunch Abbility With a crack in the floor, however , If i jump It still Is going to the same Position as if im not jumping meaning it will be in the air. How can i fix this?
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local Plr = game.Players.LocalPlayer
repeat task.wait() until Plr.Character
local char = Plr.Character or Plr.CharacterAdded:Wait()
local Humanoid = char:WaitForChild("Humanoid")
local HRP = char:WaitForChild("HumanoidRootPart")
local damage = 30
local Fists = script.Parent.Parent
local Swing = script:WaitForChild("Swing")
local CD = false
local Debounce = false
local PunchLanded = false
local FistsEquipped = false
local GroundPunch = script:WaitForChild("GroundPunch")
local GroundPunchTrack = Humanoid:LoadAnimation(GroundPunch)
Fists.Equipped:Connect(function()
FistsEquipped = true
Fists.Unequipped:Wait()
FistsEquipped = false
end)
UIS.InputBegan:Connect(function(input)
if FistsEquipped then
if input.KeyCode == Enum.KeyCode.E then
if not CD then
PunchLanded = true
GroundPunchTrack:Play()
wait(0.15)
Swing:Play()
wait(0.25)
local FloorCracksClone = RS.FloorCracks:Clone()
FloorCracksClone.CFrame = HRP.CFrame * CFrame.new(0,-3,0)
FloorCracksClone.Parent = workspace
wait(2.5)
FloorCracksClone:Destroy()
PunchLanded = false
end
end
end
end)
UIS.InputBegan:Connect(function(input)
wait(0.25)
if input.KeyCode == Enum.KeyCode.E then
if PunchLanded == true then
if not CD then
CD = true
local Event = nil
local Hitbox = RS.GroundPunchHB:Clone()
Hitbox.CFrame = HRP.CFrame * CFrame.new(0,-3,0)
Hitbox.Parent = workspace
Event = Hitbox.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
if hum and hum.Parent.Name ~= Plr.Name then
if not Debounce then
Debounce = true
local Indicator = RS:WaitForChild("DmgIndicator")
if Indicator then
if PunchLanded == true then
wait(0.1)
local gui = Indicator:Clone()
gui.Parent = hit.Parent.HumanoidRootPart
gui.Shadow.Text = "-"..tostring(damage)
gui.Shadow.Damage.Text = "-"..tostring(damage)
gui.StudsOffset = Vector3.new(math.random(-2,2), math.random(-2,2), math.random(-2,2))
local TweenDamageGui = game:GetService("TweenService"):Create(gui, TweenInfo.new(1, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out, 0, false), {Size = UDim2.new(1.5, 0 , 1.5 , 0)})
TweenDamageGui:Play()
game.Debris:AddItem(gui, 1.5)
wait(0.1)
hum:TakeDamage(damage)
wait(0.3)
Debounce = false
end
end
end
end
end)
local weld = Instance.new("ManualWeld")
weld.Part0 = Hitbox
weld.Part1 = HRP
weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
weld.Parent = weld.Part0
wait(0.1)
Event = nil
Hitbox:Destroy()
wait(3)
CD = false
end
end
end
end)
Thats what happens when i jump and Click.