-
What do you want to achieve? Keep it simple and clear!
So what i want here is to make sound display the actual sound length -
What is the issue? Include screenshots / videos if possible!
the TestSound instance always returning 0. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Tried doing Task.Delay, putting the instance creation in the function, any answers on dev hub didn’t work for me.
local function Validate(id)
if not id or not tonumber(id) then return false end
local success, result = pcall(function()
return game:GetService("MarketplaceService"):GetProductInfo(id)
end)
if success and result and result.AssetTypeId == 3 then
return true
else
return false
end
end
local Result = Validate(script.Parent.Text)
if Result then
local TestSound = Instance.new("Sound")
TestSound.SoundId = "rbxassetid://"..tonumber(script.Parent.Text)
TestSound.Volume = 0.001
TestSound.Looped = false
TestSound.RollOffMode = Enum.RollOffMode.Inverse
TestSound:Play()
task.wait(1)
print(TestSound.TimeLength)
if TestSound.TimeLength < 5 then
print(TestSound)
event:FireServer(script.Parent.Parent, script.Parent.Parent.Parent.Parent.Graphics.SoundID,Result,tonumber(script.Parent.Text))
else
print(TestSound)
script.Parent.Text = ""
script.Parent.Parent.Parent.Parent.Graphics.SoundID.TextBox.Text = ""
end
else
script.Parent.Text = ""
script.Parent.Parent.Parent.Parent.Graphics.SoundID.TextBox.Text = ""
end