In my game I have a mechanic to dodge and the system works after it is used the second time
I know the script runs since the animation plays and the system works after the second time
I print out the parent of the object and it SAYS that it is where it is supposed to be except the fact that it isn’t there
This may be a bug instead of a scripting error cause I don’t see anything I can fix
-- My entire code about this segment
function combat:Dodge(player)
if player:GetAttribute("InCombat") == true then
if emotes[player.UserId].IsPlaying == true then return end
if player.Character == nil then return end
if os.clock() - dodges[player.UserId].LastTick > 0.25 then
dodges[player.UserId] = {LastTick = os.clock(), isDodging = true}
player.Character.Humanoid.AutoRotate = false
local direction = player.Character.Humanoid.MoveDirection * Vector3.new(1,0,1)
if direction == Vector3.new(0,0,0) then
direction = player.Character.HumanoidRootPart.CFrame.LookVector * Vector3.new(1,0,1)
end
local bodyVel = Instance.new("BodyVelocity")
bodyVel.Parent = player.Character.PrimaryPart
bodyVel.MaxForce = Vector3.new(math.huge,1,math.huge)
local mass = 0
for _,v in pairs(player.Character:GetChildren()) do
if v:IsA("BasePart") then
mass += v.Mass
end
end
bodyVel.Velocity = direction * (mass * 2)
local animation = playAnim.PlayAnim(player, dodgeAnims.Forward) -- this is a seperate module that works completely fine
game:GetService("Debris"):AddItem(bodyVel, animation.Length) -- I moved this from the task.spawn and it changes nothing
task.spawn(function()
task.wait(animation.Length)
dodges[player.UserId].isDodging = false
player.Character.Humanoid.AutoRotate = true
end)
end
end
end
PS: I waited for 5 seconds when making the instance and the same results appeared