Seen here, the dummy on the right, when hit, doesn’t seem to trigger the touched event
the dummy on the left who is closer, seems to trigger the touched event immediantly
It takes a while until the dummy on the right starts registering the touched events.
--Services
local runService = game:GetService("RunService")
local tweenService = game:GetService("TweenService")
local players = game:GetService("Players")
--Main Data
local localplayer = players.LocalPlayer
--Main Functions
local module = {
fireAttack = function(attackData)
local owner = attackData.Owner
local mouseLocation = attackData.MouseLocation
local originLocation = attackData.OriginLocation
local weapon = attackData.Weapon
local shot = Instance.new("Part")
shot.Size = Vector3.new(1,1,1)
shot.Anchored = true
shot.CanCollide = false
shot.Material = Enum.Material.Neon
shot.CastShadow = false
local shotAttachment1 = Instance.new("Attachment",shot)
local shotAttachment2 = Instance.new("Attachment", shot)
local shotTrail = Instance.new("Trail", shot)
shotAttachment1.Position = Vector3.new(0.5,0,0)
shotAttachment2.Position = Vector3.new(-0.5,0,0)
shotTrail.Attachment0 = shotAttachment1
shotTrail.Attachment1 = shotAttachment2
shotTrail.WidthScale = NumberSequence.new(1,0)
shotTrail.Lifetime = 1
shot.CFrame = CFrame.new(originLocation, mouseLocation)
shot.Parent = workspace
local ignoreList = owner.Character:GetChildren()
for i = 1, 150 do
shot.Position = shot.Position + shot.CFrame.lookVector
local hitRay = Ray.new(shot.Position, shot.CFrame.lookVector)
local hitPart = workspace:FindPartOnRayWithIgnoreList(hitRay, ignoreList, false, false)
if hitPart then
if hitPart.CanCollide == true then
break;
else
table.insert(ignoreList, #ignoreList + 1, hitPart)
end
end
runService.Heartbeat:Wait()
end
local hitIgnoreList = {}
shot.Touched:Connect(function(hitPart)
if localplayer == owner then
print("Hit!")
local hitModel = hitPart.Parent
if hitModel and hitModel:FindFirstChild("Humanoid") and hitIgnoreList[hitModel] == false then
hitIgnoreList[hitModel] = true
print("Dealt Damage!")
end
end
end)
shot.Size = Vector3.new(0,0,0)
shot.CFrame = shot.CFrame * CFrame.Angles(math.random(-2,2),math.random(-2,2),math.random(-2,2))
local shotExpandInfo = TweenInfo.new(0.5,Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, 0, true)
local shotExpand = tweenService:Create(shot, shotExpandInfo, {Size = Vector3.new(10,10,10), Transparency = 0.7})
shotExpand:Play()
shotExpand.Completed:Connect(function()
shot:Destroy()
end)
end
}
return module
this is the script that handles the projectile, not sure what i am doing wrong for this to happen