Ok so I’ve been having this godawful issue in my game for the past couple of days, and I still have no Idea how to fix it. Basically, what my script is, is that when the cannonball is touched, spawn an explosion at the position at the cannonball. For some reason, it’s getting the position of where the cannonball was like a quarter of a second ago. If you want my code, here:
c.Touched:Connect(function(Hit)
if Hit.Parent:IsA("Accessory") then return end
if Hit.Parent:FindFirstChild("Humanoid") then return end
if Hit.Parent.Parent:FindFirstChild("Humanoid") then return end
if not Hit:IsDescendantOf(SpecifiedUnit.Parent) and TouchDebounce == false then
TouchDebounce = true
local Explosion = Instance.new("Explosion")
Explosion.ExplosionType = Enum.ExplosionType.NoCraters
Explosion.Position = c.Position
Explosion.Parent = game.Workspace
Explosion.BlastRadius = 5
Explosion.DestroyJointRadiusPercent = 0
Explosion.BlastPressure = 0
local SoundPart = Instance.new("Part")
SoundPart.CanCollide = false
SoundPart.Parent = game.Workspace
SoundPart.Anchored = true
SoundPart.Transparency = 1
SoundPart.Name = "Sound"
SoundPart.Size = Vector3.new(.05,.05,.05)
SoundPart.Position = c.Position
local Sound = game.ReplicatedStorage.Sounds.Explosion:Clone()
Sound.Parent = SoundPart
Sound:Play()
Debris:AddItem(SoundPart,5)
Explosion.Hit:Connect(function(Object)
if Object.Parent then
if Object.Parent:FindFirstChild("Humanoid") then
Object.Parent.Humanoid.Health = 1
CalculateDamage(SpecifiedUnit,Object.Parent)
end
end
end)
end
end)
Does anyone know why this is happening?