Volontary put an instance that will be destroyed so the error should be index nil with SoundId
System Information:
Windows 11 Pro 24h2
Beta Features:
New luau solver
Assistant Preview
A private message is associated with this bug report
Volontary put an instance that will be destroyed so the error should be index nil with SoundId
System Information:
Windows 11 Pro 24h2
Beta Features:
New luau solver
Assistant Preview
A private message is associated with this bug report
Note: There is no pcalls without printing or warning, the only pcall are used to handle characters to prevent adding more check that could affect performances on the server.
I’m confused why it would error there, you created the sound and then in the loop below you set the SoundId and wait 16 seconds before destroying it. You should try reproducing it just in a normal script to see if it would do the same thing. I’m not sure that destroying it would set the variable to nil.
What i mean in the loop it create only one sound at the top variable and destroy it on the loop so the sound turn into nil. Rn the script stop but nonerror type index nil with SoundId is displayed which is anormal
I think its possible that the variable isn’t actually being set to nil. You destroyed it but that only locks the parent property and clears connections. Set the variable to nil after destroying it and see if that errors.
Then we should get a parent is locked error. At the time the module just stop and doesnt show anything
Well you didn’t try to change the parent, you just set the SoundId property. It wouldn’t make sense to error there. Maybe a warning for trying to use a Destroyed instance, but not an error
It shoud normally have a attempt to index nil with SoundId error.
Well is the variable nil? If not then it wouldn’t error
Could you add prints and check, also make the wait less so its better (Also why you use “wait”, I prefer task.wait())
Also agree to the reply above, it shouldn’t error if you don’t set it to nil
(Also, Roblox, fix the ordered datastores .IsFinished page thingy)
Then if it shouldn’t error it shouldn’t stop the module aswell
Hi,
Thank you for checking in on this.
According to the documentation for Destroy() the Instance itself will not become nil
when Destroy()
is called upon it. As a best practice, you should set it to nil
.
Even if you set it to nil
though, the type system doesn’t know that it shouldn’t be nil
unless you tell it so by declaring its type:
local sound : Sound? = Instance.new("Sound", workspace)
will result in the correct errors: