Im making a tornado system, and when a part gets sucked in by it then it makes a “destroy” sound. But these sound are of course different, e.g for glass there’s glass breaking sound. The problem is, that even if it’s not a glass part, it everytime makes a glass destroying sound. Here’s the script:
local sound = script.BreakSound
local glassound1 = script.GlassSound
if not script.Parent.Parent.Parent:FindFirstChild("Humanoid") then
if script.Parent.Parent.Material ~= Enum.Material.Glass then
if not script.Parent.Parent:FindFirstChildWhichIsA("BreakSound") then
local sound1 = sound:Clone()
sound1.Parent = script.Parent.Parent
sound1:Play()
sound1:Destroy() -- Play on remove is turned on
script:Destroy()
end
else
if not script.Parent.Parent:FindFirstChildWhichIsA("GlassSound") then
local glasssound = glassound1:Clone()
glasssound.Parent = script.Parent.Parent
glasssound:Play()
glasssound:Destroy() -- Play on remove is turned on
script:Destroy()
end
end
else
script:Destroy()
end
I believe it’s because you’re using ‘FindFirstChildWhichIsA’ rather than the one you want to be using, ‘FindFirstChild’. Using FindFirstChildWhichIsA(string type) is a way to find a child of an object based on the TYPE of object it is, not the name of it.
Try this:
local sound = script.BreakSound
local glassound1 = script.GlassSound
if not script.Parent.Parent.Parent:FindFirstChild("Humanoid") then
if script.Parent.Parent.Material ~= Enum.Material.Glass then
if not script.Parent.Parent:FindFirstChild("BreakSound") then
local sound1 = sound:Clone()
sound1.Parent = script.Parent.Parent
sound1:Play()
sound1:Destroy() -- Play on remove is turned on
script:Destroy()
end
else
if not script.Parent.Parent:FindFirstChild("GlassSound") then
local glasssound = glassound1:Clone()
glasssound.Parent = script.Parent.Parent
glasssound:Play()
glasssound:Destroy() -- Play on remove is turned on
script:Destroy()
end
end
else
script:Destroy()
end
Also, I have another problem with my tornado. It basically just vanishes after unanchoring it. I tried changing the name(I thought maybe something was deleting it), but it still didn’t work.
I think it’ll be falling through the world if it’s can collide is false. It also depends how you’re moving the tornadoes too. I don’t see anything wrong with keeping them anchored and letting a loop, like a .Stepped event moving them.
Ahhh okay, so for the AlignPosition object, is it connected to an attachment that’s within an anchored part? You’ll want that anchored part to always be anchored.
Align Position is set to One attachment mode, and when the storm begins, the script inside it enables and starts aligning random position within the cloud.