Random Sound Play Not Working

I have code to randomly play sound of folder in workspace, but it says index to :play on :play line error

code

while wait(math.random(1,10)) do
	local item = workspace.Sounds:GetChildren()
	local randomitem = math.random(#item)
	randomitem:Play()
end

Yeah, because what you are doing is not how that works

You are getting a Random Number and Telling the Code to “Play” it, you Cannot play a number, the code is just saying to get a random based on the number of Children within the Instance.

Do you mean this?

local randomitem = item[math.random(1, #item)]
1 Like

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