Hello. I have a weapon on Roblox that shoots out projectiles. I added a creator tag into the script and now the projectiles no long deal damage to players. How can I fix this?
function OnRayHit(cast, raycastResult, segmentVelocity, cosmeticBulletObject)
-- This function will be connected to the Caster's "RayHit" event.
local debreeService = game:GetService("Debris")
local function tagHumanoid(humanoid, player)
local creator_tag = Instance.new("ObjectValue", humanoid)
creator_tag.Name = "creator"
creator_tag.Value = player
Debris:AddItem(creator_tag, 9)
end
local function untagHumanoid(humanoid)
for i, v in pairs(humanoid:GetChildren()) do
if v:IsA("ObjectValue") and v.Name == "creator" then
v:Destroy()
end
end
end
local hitPart = raycastResult.Instance
local hitPoint = raycastResult.Position
local normal = raycastResult.Normal
if hitPart ~= nil and hitPart.Parent ~= nil then -- Test if we hit something
local function onDamage(player, target, damage)
local humanoid = hitPart.Parent:FindFirstChildOfClass("Humanoid") -- Is there a humanoid?
untagHumanoid(humanoid)
tagHumanoid(humanoid, player)
if humanoid then
humanoid:TakeDamage(100) -- Damage.
end
MakeParticleFX(hitPoint, normal) -- Particle FX
end
end
end
I’m assuming I just need to move some stuff around as I don’t even get any errors in the output. But if you know how to fix this please let me know, thank you.