This is what I have in the classic paintball gun, from line 29 in 'Paintball'
if humanoid ~= nil or localplayer then
tagHumanoid(humanoid)
humanoid:TakeDamage(damage)
wait(1)
untagHumanoid(humanoid)
end
The entire script:
ball = script.Parent
damage = 50
function onTouched(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if hit:getMass() < .5 * 200 then
hit.BrickColor = ball.BrickColor
end
for i=1, 1 do
local s = Instance.new("Part")
s.Shape = 1
s.formFactor = 2
s.Size = Vector3.new(1,.4,1)
s.BrickColor = ball.BrickColor
local v = Vector3.new(math.random9(-1,1), math.random(0,1), math.random(1,1))
s.Velocity = 15 * v
s.CFrame = CFrame.new(ball.Position + v, v)
ball.BrickCleanup:clone().Parent = s
s.BrickCleanup.Disabled = false
s.Parent = game.Workspace
end
if humanoid ~= nil then
tagHumanoid(humanoid)
humanoid:TakeDamage(damage)
wait(1)
untagHumanoid(humanoid)
end
connection:Disconnect()
ball.Parent = nil
end
function tagHumanoid(humanoid)
local tag = ball:FindFirstChild("creator")
if tag ~= nil then
local new_tag = tag.clone()
end
end
function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:FindFirstChild("humanoid")
if tag ~= nil then
tag.Parent = nil
end
end
end
connection = ball.Touched:connect(onTouched)
wait(3)
ball.Parent = nil

5 comments
I need the script to check if the player that touched the paintball is the player that shot it so they won't get damaged. I added the entire script to the question so you can see what I need to add.
Okay I see that the script you provided is inside the paintball, right? So, what you could do is add an attribute inside the ball and set the name to "playerThatShot" and set the value to the player's name. If you've never used attributes, they're pretty much like custom properties that you can add to an object.
So, navigate to wherever you are shooting the ball (assuming its a script inside the tool itself, you can get the player's character by using script.Parents) and set the attribute value to the character's name. And now you can get this attribute to check to see if the characters' name that was hit by the ball is the same as the player that shot it.
^ Hopefully its not too confusing. If you're having trouble with Attributes there are tutorials on youtube that shows you how they work (or google Attributes for roblox (should be the first link) and on the page it'll tell you how they work and you'll also be able to find all the functions and events for attributes).
When I use SetAttribute, I get the error "Instance is not a supported attribute type" when I shoot the gun, and the ball doesn't get created.