I made this carrying system a few days ago that im currently really proud of, today i found this game breaking bug that could mess up some players and purposely glitch out people so they are forced to rejoin, making them lose all data because of my combat tagging system:
Explanation
The glitch happens when 2 knocked characters are near eachother, one of them will be carried then instantly dropped, putting them in this limbo kind of state where they cant be picked up and arent able to stand up
Possible problems
im currently using magnitude to identify if a character is knocked, im not giving out my full script as i think magnitude is the problem behind this bug:
local distance = (CHARACTER.HumanoidRootPart.Position - v.HumanoidRootPart.Position).magnitude
if distance <= range and v.Character.Values.Downed.Value == true and v.Character.Values.BeingCarried.Value == false and CARRYING == false then
CARRYING = true
Authorized = false
v.Character.Values.Ragdolled.Value = false
v.Character.Values.BeingCarried.Value = true
Id love to see someone explain to me why this bug occurs and give me a possible fix so this doesnt cause anymore problems later in development.
Since you are looping through the workspace and seeing how close they are to you (I’m assuming that’s what you are doing.) why don’t you just return it when it finds one player so it can’t pick up 2 or more players?
Yeah, returning would allow you to pick up one of the players instead of picking them both up. Put return at the end of the code where the script does all the other things.
for i, v in pairs(game.Workspace:GetChildren()) do
local distance = (CHARACTER.HumanoidRootPart.Position -v.HumanoidRootPart.Position).magnitude
if distance <= range and v.Character.Values.Downed.Value == true and v.Character.Values.BeingCarried.Value == false and CARRYING == false then
--The carrying code RIGHT here before the return. It will get only player within the distance.
return
end
end