How to get .touched to fire when changing its size?

I’m trying to recreate a sonar effect from Splinter Cell Conviction, where any person inside the radius of the sphere would get highlighted. However the .touched event doesn’t seem to fire while it’s size is being changed. Is there another way to go about this?

You can try Explosion.Hit

Once you expand the sphere use Sphere:GetPartsInPart() to get an array of parts that are inside the sphere. Then loop through the array to see if the part is a character. We are also gonna need a table to store recorded characters since many parts of the character could be inside. Then you could highlight them however you would

local CIS = {}
local sphere = script.Parent
local TS = game.TweenService
local t = TS:Create(sphere, TweenInfo.new(2), {Size = Vector3.new(20,20,20)})
t:Play()
wait(2)
for i, part in ipairs(sphere:GetPartsInPart()) do
   if not part.Parent:FindFirstChild('Humanoid') then continue end
   if table.find(CIS,part.Parent) then continue end
   table.insert(CIS,part.Parent)
end)
for _,char in ipairs(CIS) do
   HighlightChar() -- Highlighting function if you have one
end

maybe try regoin3 or zone+ or have an invisible block that will fire the event instead

1 Like

Unfortunately I need to it scan as it’s being sized up.

I forgot entirely about this module, thanks for bringing this up. It’s been fixed!

1 Like

Understood. Then try this snippet of code instead

local H = {}
local tweenCompleted = false

-- Assuming tween is a TweenInstance
tween.Completed:Connect(function()
    tweenCompleted = true
end)

repeat
    for i, part in ipairs(sphere:GetPartsInPart()) do
        if not part.Parent:FindFirstChild('Humanoid') then continue end
        if table.find(H, part.Parent) then continue end
        HighlightChar(part.Parent)
        table.insert(H, part.Parent)
        task.wait(.1)
    end
    -- Wait for the tween to complete
    task.wait(0.1)
until tweenCompleted

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.