Player somehow becomes invincible

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Help me fix a weird bug pls
  2. What is the issue? Include screenshots / videos if possible!

    Basically this is a counter move from my pvp game, and this script checks when the plr gets dmg when in counter move. The issue is when the skill is activated, the plr became invincible to all sort of dmg(which uses touched event to trigger the damaging)
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried looking for solutions but i can not find anything related
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

2 Likes

Just a guess tbh cuz it looks fine except for something I don-t recognize.

Try removing the 1 from the for loop.

Do for i=1, 90 do instead of 1,90,1

the last 1 is just the number increase everytimes it loops

Pretty sure the number increases naturally.

so basically wat happens here is the red part i touched is scripted to dmg the plr after 1 sec and the counter worked. But when tested with the red ball(and other skills) it just went right through. This is just a budget game i make 4 fun tho c:

Is the code not supposed to prevent damage during the counter?

Maybe you character dies and set the health value back to a positive number and glitches the character?? We need more information, do you change the collision group in some script? can we see a bit of code of the red orb?

i recomend adding a boolean value inside the character, and when a projectile wants to damage the player, checks the boolean, if its true it does not, if its false it does, but you will have to set that value from the server side

1 Like

yeah but it also triggers the counter which is that big white ball thing that deals dmg and stun

local tagged = {}

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		local team = nil
		if plr then 
			team = plr.Team.Name 
		end
		
		if plr then
			if team ~= script.Parent.Team.Value then
				local check = true
				for i,obj in pairs(tagged) do
					if obj == hit.Parent then
						check = false
					end
				end
				
				if check then
					hit.Parent.Humanoid.Health -= script.Parent.DMG.Value
					table.insert(tagged,hit.Parent)
				end
				
			end
		else			
				local check = true
				for i,obj in pairs(tagged) do
					if obj == hit.Parent then
						check = false
					end
				end

				if check then
					hit.Parent.Humanoid.Health -= script.Parent.DMG.Value
					table.insert(tagged,hit.Parent)
				end
		end
	end
end)

the hit script of red orb here and no i dont change collision group

2 Likes

the red orb is hitting the sword tool handle maybe and does not hit the character?
how do you move the orb? make some print to know in the code

no i tried multiple angles off cam and also tried it with some big aoe moves and it still didnt work. i use tween to move em

1 Like

mmm i dont know, maybe try commenting (ctral + /) this part of code

char.Humanoid.Health = lastHP

but maybe the problem is in another script, or in a part the screenshot does not show

1 Like

what is that clone variable? and are you changing some sort of collision of the player? do projectiles hit the character and dont do damage or dint hit at all?

1 Like

I’m cloning the red ball from server storage, and projectiles hits the char and deal no dmg

2 Likes

did u watch the vid i sent tho

1 Like

yes and im thinking why does not do damage but i have no clue

2 Likes

yeah i tried printing it out and it really did not touch when the other plr was in counter mode

1 Like

maybe it hits the handle?
try

local plr = game.Players:GetPlayerFromCharacter(hit.Parent) or game.Players:GetPlayerFromCharacter(hit.Parent.Parent) or game.Players:GetPlayerFromCharacter(hit.Parent.Parent.Parent) 

or maybe its the way you move the orb buts its weired (like teleporting it with cframes)

2 Likes

welp it doesnt work :c dont really think its the way it moves tho cus it does touch the torso

2 Likes

Well, the best that you can do now is place a lot of prints or warns around the code and figure why they hit but dont deal damage, or if they deal damage and the character heals itself (in both scripts)

1 Like