Roblox touched event firing in advance?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

i want the fireball to explode when it hits something, but it seems it explodes in advance?

  1. What is the issue? Include screenshots / videos if possible!

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i have tried looking but there wasnt much info

heres my code

local db = false

local bodyvelocity = Instance.new("BodyVelocity",script.Parent)
bodyvelocity.P = math.huge
bodyvelocity.Velocity = CFrame.lookAt(script.Parent.Position,script.Parent.Value.Value.Position).LookVector * 50
bodyvelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
task.wait(0.5)

script.Parent.Touched:Connect(function(part)
		script.Parent.Anchored = true
		if db == false then
			print("doin")
			script.Parent.Anchored = true
			print("destroying")
			db = true
			if script.Parent:FindFirstChild("explosion") then
				script.Parent.explosion:Destroy()
			end
			script.Parent.Size = Vector3.new(8,8,8)
			for i,part in workspace:GetPartsInPart(script.Parent) do
				if part.Name == "HumanoidRootPart" then
					part.Parent.Humanoid:TakeDamage(20)
				end
			end
			game:GetService("TweenService"):Create(script.Parent,TweenInfo.new(1),{Transparency = 1}):Play()
			wait(1)
			script.Parent:Destroy()
			script.Enabled = false
		end
	
end)
2 Likes

Make a smaller part within the fireball and put the script within there

1 Like

its still going to touch early, and its going to have a hitbox thats not accurate

1 Like

Assuming this is a server script, it’s likely just visual delay. You can confirm it by printing hit assuming your hitbox is correctly sized. The best solution would be client rendering of the fireball.

yea but its still rather annoying, i would like to make it sync both on server and client (and yes its server side)

You’re never going to get perfect syncing of the server and client, that’s just how networking works.

Action client renders for zero input and render delay → server validates and handles the damage and sends it to other clients for rendering → other clients renders for zero render delay

im if else, im just looking to see how i can make fireball hitboxes. how do the other game do it?

i HAVE tried using raycasting method to tp the bal lwhere it touches so it replicates across all cients, but the problem is that now the hitbox is just a small ray, therefore it passes through almost everything if it doesn’t detect in that small ray