Yes I did search this up already, but found no results. I’m trying to make a projectile. But, it damages yourself if you touch it. I know I can add a bool value with the player’s username, but I don’t want it to just destroy the projectile if it hits me.
How is your code structured right now? Are you using the .Touched event? I’d like more details if possible. And you can easily add a bool at the begin to check if the hit model is your character, if it return false then just keep going what the projectile is supposed to do.
local Bullet = script.Parent
local Damage = 15
local function TagHumanoid(Humanoid)
local CreatorTag = Bullet:FindFirstChild("creator")
if CreatorTag ~= nil then
local NewCreatorTag = CreatorTag:Clone()
NewCreatorTag.Parent = Humanoid
end
end
function UntagHumanoid(Humanoid)
if Humanoid ~= nil then
local CreatorTag = Humanoid:FindFirstChild("creator")
if CreatorTag ~= nil then
CreatorTag:Destroy()
end
end
end
local function OnTouched(Hit)
if Hit.Parent:FindFirstChild("Bullet") then return end
local Player = Bullet.creator.Value
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid and not Humanoid:IsDescendantOf(Player.Character) then
Humanoid:TakeDamage(Damage)
TagHumanoid(Humanoid)
wait(0.25)
UntagHumanoid(Humanoid)
end
Connection:Disconnect()
Bullet:Destroy()
end
Connection = Bullet.Touched:Connect(OnTouched)
wait(3)
Bullet:Destroy()
Somehting I made this for 2 hours trying to figured out