I’m trying to make a projectile that explodes upon contact with the ground. I noticed it explodes mid-air instead of touching the ground, and when I looked at the server side I noticed that the positions are desynced. It’s not a visual error because when I check the properties section they show different numbers.
Mind if I can see some of the code?
Also maybe display settings or im just stupid like difference between the physics stepping and your frame??
show me code tho
local proj = script.Parent
local triggered = false
proj.Touched:Connect(function(otherPart: BasePart)
if triggered == false then
if otherPart.Parent ~= proj and otherPart.Parent:FindFirstChild("Humanoid") == nil then
triggered = true
proj.Anchored = true
proj.particles.explosion:Emit(1)
proj.particles.sparks.Enabled = false
proj.particles.star.Enabled = false
local list = game.Workspace:GetPartsInPart(proj.Hitbox)
for _, obj in pairs(list) do
local tag = obj.Parent:FindFirstChild("ZombieTag")
if tag ~= nil then
local human = obj.Parent:FindFirstChild("Humanoid")
if human ~= nil then
if human.Health > 0 then
human.Health = human.Health - 300
if human.Health <= 0 then
local owner = proj.Owner.Value
owner.leaderstats.Credits.Value = owner.leaderstats.Credits.Value + math.ceil(human.MaxHealth / 100)
end
end
end
end
end
end
end
end)
local function falling_star(target)
if target ~= nil then
local tl = target.CFrame
local c = projectile:Clone()
local x = tl.Position.X + (math.random(-500,500) * .1)
local y = tl.Position.Y + math.random(50,51)
local z = tl.Position.Z + (math.random(-500,500) * .1)
c:PivotTo(CFrame.new(x,y,z))
local force = Instance.new("BodyVelocity")
force.MaxForce = Vector3.new(99999,99999,99999)
local force1 = CFrame.new(c.Position, target.Position).LookVector * proj_speed
force.Velocity = force1
force.Parent = c
c.Anchored = false
c.Parent = game.Workspace
end
end
top is the code for the projectile, bottom is the code for the weapon that creates the projectile.