i am basically scripting a fireball that travels in the direction of the mouse and on impact creates a part in the exact same position.
everything works just fine except for this part where if the player clicks the left mouse button during this time, the part won’t spawn in the position of the impact but in the position where the player interacted with the mouse.
i think it might be because of this line (Mouse.Hit.Position-RaycastOrigin).Unit*1000
but i don’t know how to fix the issue. any help is appreciated
local RaycastOrigin = SphereProjectile.Position
local RaycastDirection = (Mouse.Hit.Position-RaycastOrigin).Unit*1000
local RaycastParameters = RaycastParams.new()
RaycastParameters.FilterType = Enum.RaycastFilterType.Blacklist
RaycastParameters.IgnoreWater = true
RaycastParameters.FilterDescendantsInstances = {_debris,C,Character}
Connection = RunService.RenderStepped:Connect(function(deltaTime)
if Raycast(SphereProjectile.Position,Data.FinalPosition,{_debris,C},100*deltaTime,SphereProjectile) == false then
local RaycastResult = workspace:Raycast(RaycastOrigin,RaycastDirection,RaycastParameters)
if RaycastResult then
ExplosionSphere0.Position = RaycastResult.Position
ExplosionSphere1.Position = RaycastResult.Position
end
end
end)