Hello developers, I’ve came to a recent conclusion on this annoying script issue I have on my end, I’ve tried countless research and different solutions that would potentially resolve the issue itself, however I was not able to find any solution, so thus I was curious if there would be work-arounds or a way to fix this potential issue.
What am I trying to achieve?
- I’m currently trying to achieve where the player will receive fall damage based on the tick used in the code, thus mainly to take damage based on the amount they’ve fallen from distance until they’ve landed based off the time-length.
- I resort to only this as my game will contain additional teams with buffed health compared to other teams thus, that is why I want this result instead of a “max-fall-distance” amount and more-so a tick-fall time length amount.
What is the identified issue you’ve resulted in finding?
- I’ve found a identified issue based on the fact when a player has loaded or continuously jumping multiple times which results in taking damage and ragdolling.
I’d appreciate any support or help given to me!
Script Function
local VelocityConfigs = {};
VelocityConfigs.TickThreshold = .2;
VelocityConfigs.TickDamagePerSecond = 200;
VelocityConfigs.TickRagdollConfigs = {ThresholdFreefall = 1, LandThreshold = .7};
game:GetService("Players").PlayerAdded:Connect(function(Player : {[string]: "Player"})
Player.CharacterAdded:Connect(function(Character : {[string]: "Character"})
if not(Player:HasAppearanceLoaded() or Player.CharacterAppearanceLoaded) then
repeat task.wait() until Player:HasAppearanceLoaded() and Player.CharacterAppearanceLoaded;
end
local HumanoidConfigs = {IsFalling = false};
local Humanoid = Character:WaitForChild("Humanoid");
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart");
Humanoid.BreakJointsOnDeath = false;
Humanoid.StateChanged:Connect(function(OldState : {[string]: "EnumItem"}, NewState : {[string]: "EnumItem"})
if(NewState == Enum.HumanoidStateType.Dead) then
if(HumanoidConfigs.IsFalling) then HumanoidConfigs.IsFalling = false; end;
RagdollPlayerModule:SetRagdoll(Character, true);
else
if(NewState == Enum.HumanoidStateType.Freefall) then
HumanoidConfigs.IsFalling = true;
local DataConfigs = {CurrentTick = tick(), ReachTick = 0, ReachPosition = HumanoidRootPart.Position.Y, StartTick = tick()};
while task.wait() do
if(Humanoid and Humanoid.Health > 0 and (Humanoid:GetState() == Enum.HumanoidStateType.Freefall) and HumanoidConfigs.IsFalling) then
DataConfigs.CurrentTick = tick();
if(math.floor(DataConfigs.CurrentTick - DataConfigs.StartTick) >= VelocityConfigs.TickRagdollConfigs.ThresholdFreefall) then
if not(RagdollPlayerModule:GetRagdollData(Character)[2]) then
RagdollPlayerModule:SetRagdoll(Character, true);
end
end
if(HumanoidRootPart.Position.Y > DataConfigs.ReachPosition) then
DataConfigs.ReachPosition = HumanoidRootPart.Position.Y;
DataConfigs.ReachTick = tick();
end
else
break;
end
end
local ThresholdTickTime = (DataConfigs.CurrentTick - DataConfigs.StartTick);
if(ThresholdTickTime > VelocityConfigs.TickThreshold) then
local DamageTickAmount = (math.max(0, (tick() - DataConfigs.ReachTick - VelocityConfigs.TickThreshold)) * VelocityConfigs.TickDamagePerSecond);
if(Humanoid) then
if(ThresholdTickTime > VelocityConfigs.TickRagdollConfigs.LandThreshold and not RagdollPlayerModule:GetRagdollData(Character)[2]) then
RagdollPlayerModule:SetRagdoll(Character, true);
end
warn(DamageTickAmount);
if(Humanoid.Health - DamageTickAmount > 0) then
end
Humanoid:TakeDamage(DamageTickAmount);
end
end
if(RagdollPlayerModule:GetRagdollData(Character)[2] ~= true) then
task.delay(4.5, function()
if(Humanoid and Humanoid.Health > 0 and RagdollPlayerModule:GetRagdollData(Character)[2] ~= false) then
RagdollPlayerModule:SetRagdoll(Character, false);
end
end);
end
else
if(HumanoidConfigs.IsFalling) then HumanoidConfigs.IsFalling = false; end;
end
end
end);
end);
end);
- I will address anything necessary to resolve this issue.