I was trying to make a CollectionService system for one task that I’ll be using for a bunch of other stuff. They tweened fine and all, but there was no sound. I tried debugging it with prints but for some reason it just throws an error saying it doesn’t exist, which obviously does. I have no idea what to do beyond that because this is the only solution I know for this specific type of case. I know the syntax is correct because it doesn’t give any syntax errors. I’d appreciate any sort of help for me to understand what’s going on.
local function Execute(tar)
local Open = tar:GetAttribute("OpenPos")
local Closed = tar:GetAttribute("ClosedPos")
local Sound = tar:FindFirstAncestor("Sound")
print(Sound.Name) -- Throws out an error
if tar:GetAttribute("Open") then
TweenService:Create(tar, OCAnim, {Position = Closed}):Play()
tar:SetAttribute("Open", false)
else
TweenService:Create(tar, OCAnim, {Position = Open}):Play()
tar:SetAttribute("Open", true)
end
if Sound and Sound:GetAttribute("MovingOBJSFX") then
Sound:Play()
end
end
The instance I highlighted is the target in question. (The script doesn’t exist as the child because it’s in ServerScriptService)