-
I’m trying to make a system that detects a knocked player to execute but the way i’m doing it doesn’t work really well. Any suggestions/help?
-
Sometimes I see the execute text when I’m walking away from the player and the text is still here
-
As you can see in my code I tried running a loop
task.spawn(function()
while Hum.Health > 0.01 do task.wait(Settings.WAIT_TIME) -- While the player is in an alive state keep searching for a player that can be gripped
if Hum.Health <= 0.01 or Possible or isGripping then return end -- If there is a possible player in range then hold up
for _, PossiblePlr in Players:GetPlayers() do
print("Looking for a player that can get executed")
if PossiblePlr:IsA("Player") then print("Client might of found a player") -- Confirm if the typeof value is a Player (will be changed for NPCs later in development)
if PossiblePlr.Character["IsKnocked"].Value and Hum.Health > 0.01 and PlrTable:CheckConditions("canGrip") and (Root.Position - PossiblePlr.Character.PrimaryPart.Position).Magnitude <= Settings.GRIP_MAG and not isGripping then -- Self-explainatory
Possible = true
GripUi.Enabled = true
CanGrip:InvokeServer(PossiblePlr.Character, Settings.GRIP_MAG)
--else
-- Possible = false
-- GripUi.Enabled = false
print(Possible)
if CanGrip and PossiblePlr.Character["IsKnocked"].Value and Hum.Health > 0.01 and PlrTable:CheckConditions("canGrip") and (Root.Position - PossiblePlr.Character.PrimaryPart.Position).Magnitude <= Settings.GRIP_MAG and Possible and not isGripping then
print(Possible)
Possible = true
print("table insert")
CanGrip = nil
else
CanGrip = false
GripUi.Enabled = false
warn("Error while process.")
Possible = false
--return
end
end
end
end
end
end)