I am having trouble making it so if an attack is casted by a person, the damage won't hurt the user. I've originally tried making it where the damage brick's parent is the char and if the brick touches the user it references whether or not it's the parent's humanoid. This works in studio and the problem of self-harm is fixed but for some reason, in-game the bricks just end up being invisible to other players . Not sure if this is something that has to do with Filtering Enabled but I'm wondering if there are other ways to turn off self-harm to attacks.
You could add a a creator value in the user, it can be any value like:
local creator = Instance.new("IntValue") -- IntValue local player = game.Players.LocalPlayer -- the user creator.Name = (player.Name) -- setting the value to the players name, so it doesnt get mixed up creator.Parent = player.Character -- putting it in the player
and if the attack tries to damage the user you can make a if statment in the damage script like this:
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild(player.Name):IsA("IntValue") then -- makes sures if its the right value print("lol dont attack me") -- change this else print("good boy") -- change this end
this is what most weapons use lol, idk if it works bc i just made it up lol, hope it helpssssssss and change it to fit your script.
Hello, NikkoTheJesusMan!
I had the same problem, until i found a way to prevent it!
So, let me give you an EXAMPLE :
script.Parent.Touched:Connect(function(hit) -- Example, put this as a LocalScript in a weapon! if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= game.Players.LocalPlayer.Name then -- If the player's name isn't same as the tool user then... -- Do the things you want to do! hit.Parent.Humanoid:TakeDamage(10) end) -- Note: Didn't check on studio! -- This is just an example!
So, the second line detects if there is a HUMANOID and the player's name is same as the tool user!
-- Hope i helped, if you had other problems then, comment them!
---- AIphanium.