Checking what player summoned the attack and not damaging them

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!
    I want the hitbox code to actually work and not damage the person who summoned the attack.
  2. What is the issue? Include screenshots / videos if possible!
    I’ve done some debugging and it appears to be something wrong with the owner value code in the if statement, if I take it out of there it seems to damage other players, but it includes whoever summoned the attack I want it to not damage the owner.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried a couple google searches and a couple devforum searches.
    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!
local PlayersAlreadyHit = {}
local ownerchar = workspace:FindFirstChild(script.Parent.Parent.Owner.Value)
local ownerplayer = game.Players:GetPlayerFromCharacter(ownerchar)
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Dataz") and not hit.Parent.Name == ownerchar.Name then
		if hit.Parent.Information:FindFirstChild("CanDodge") and hit.Parent.Information:FindFirstChild("Dodge").Value > 0 and not table.find(PlayersAlreadyHit, hit.Parent.Name) then
			local DodgeAnim1 = game.ServerStorage.Anims.Dodge1
			local DodgeAnimLoad = hit.Parent:WaitForChild("Humanoid").Animator:LoadAnimation(DodgeAnim1)
			hit.Parent.Information:FindFirstChild("Dodge").Value = hit.Parent.Information:FindFirstChild("Dodge").Value - 5
			DodgeAnimLoad:Play()
			table.insert(PlayersAlreadyHit, hit.Parent.Name)
			wait(0.4)
			table.remove(PlayersAlreadyHit, hit.Parent.Name)
		else
			if not table.find(PlayersAlreadyHit, hit.Parent.Name) then
				hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 5
					table.insert(PlayersAlreadyHit, hit.Parent.Name)
			end
		end
	end
end)

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.

1 Like

Try adding him to the table like this

script.Parent.Touched:Connect(function(hit)
	table.insert(PlayersAlreadyHit , ownerPlayer)

I did some tweaking and it worked, thanks a lot!

1 Like