What my error looks like: http://imgur.com/a/cF5cw
Important notes: The bullet destroys itself when it detects the collision The gray area is the actual part The character is controlled through CFrame and is anchored. The projectile uses velocity to move
As you can see, collisions aren't being detected at all, or are being detected before the client ever sees the parts collide. I have tried using custom collision as well as the simple part.Touched:connect(function() end)
event, but both either go off too early or not at all. What did I mess up?
-The Code
function fire(direction) local projectile = Instance.new("Part", workspace) projectile.Name = "Projectile" projectile.CFrame = CFrame.new(char.Head.Position, char.Head.Position + direction) local spawnPos = projectile.Position projectile.Velocity = Vector3.new(direction.X * projectileSPD, 0, direction.Z * projectileSPD) projectile.CanCollide = false projectile.Size = Vector3.new(.7, 0.2, 3.06)--(.1,.1,.1)--(.7, 0.2, 3.06) projectile.Transparency = 0 local surfacegui = Instance.new("SurfaceGui") surfacegui.Face = "Top" surfacegui.Parent = projectile local image = Instance.new("ImageLabel") image.BackgroundTransparency = 1 image.Image = projectileImage image.Position = UDim2.new(0,-100,0,-100) image.Size = UDim2.new(0,1000,0,800) image.Parent = surfacegui local potentialHits = {} spawn(function() while projectile and wait(0.1) do if (projectile.Position - spawnPos).magnitude >= range then projectile:Destroy() end projectile.Velocity = Vector3.new(direction.X * projectileSPD, 0, direction.Z * projectileSPD) end end) projectile.Touched:connect(function(otherPart) if otherPart.Parent:FindFirstChild("PlayerID") and otherPart.Parent:FindFirstChild("Health") then local damage2 = math.max(damage*0.15, damage - (otherPart.Parent.Stats.Defence.Value.X + otherPart.Parent.Stats.Defence.Value.Y)) otherPart.Parent:FindFirstChild("Health").Value = otherPart.Parent:FindFirstChild("Health").Value - damage2 projectile:Destroy() end if otherPart.Parent ~= script.Parent and otherPart.Name == "Wall" then projectile:Destroy() end end) wait(math.random(cooldown - cooldownrange, cooldown + cooldownrange)) end
-Edit 2 http://imgur.com/a/83oW0 - Most recent code It is now hitting except the hitboxes are still messed up