Hello!
I was just wondering if :GetTouchingParts() worked to detect an object that is mid-tween if that makes sense?
For example, I have a cannon that fires a projectile at a boss, and I’m trying to detect when the hit happens, so I was planning on using :GetTouchingParts() to detect this “touch” without unanchoring the part.
Here’s my script, it appears not to work.
buttonFunction = coroutine.wrap(function(button, proj)
local core = workspace:WaitForChild('Boss').HumanoidRootPart
local RS = game:GetService('ReplicatedStorage')
local tweenService = game:GetService('TweenService')
local deb = false
local pressed = false
local event = RS.Events.Finish
if pressed == false then
pressed = not pressed
button.Parent.Fired.Value = true
tweenService:Create(button, TweenInfo.new(0.5), {Position = Vector3.new(button.Position.X, button.Position.Y - 0.45, button.Position.Z), Transparency = 0.5}):Play()
proj.CFrame = CFrame.lookAt(proj.Position, core.Position)
proj.Anchored = true
local tween = tweenService:Create(proj, TweenInfo.new(5), {Position = core.Position})
tween:Play()
button.Sound:Play()
repeat print(proj:GetTouchingParts()) wait() until table.find(proj:GetTouchingParts(), core) -- seems to print '{}' infinitely despite there being touching parts.
if deb == false then
deb = true
print('core')
local part = Instance.new('Part', workspace)
local health = core.Parent:WaitForChild('Health')
health.Value = health.Value - 100
part.Anchored = true
part.CanCollide = false
part.Transparency = 1
part.Position = proj.Attachment.WorldPosition
local exp = RS.Assets.ParticleEmitter:Clone()
local val = Instance.new('NumberValue', exp)
exp.Parent = part
exp:Emit(1)
tweenService:Create(val, TweenInfo.new(2), {Value = 100}):Play()
val:GetPropertyChangedSignal('Value'):Connect(function()
exp.Size = NumberSequence.new(val.Value)
end)
finish(button.Parent)
end
end
end)
TIA for the help!