Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with SoudIds?

This is my first time changing a SoudId with a script, and, without surprise, I got an error thrown at me:

09:51:52.437 - Workspace.Rounds:5: attempt to index global 'newid' (a number value) 09:51:52.438 - Stack Begin 09:51:52.439 - Script 'Workspace.Rounds', Line 5 - global FindEnd 09:51:52.439 - Script 'Workspace.Rounds', Line 105 - global Classic 09:51:52.440 - Script 'Workspace.Rounds', Line 200 - global ChooseRound 09:51:52.443 - Script 'Workspace.Rounds', Line 213 09:51:52.445 - Stack End


ids = {225032798,225032815,225032806,225032853,225032784,225032834,224971324}
function FindEnd()
	newid = ids[math.random(1,#ids)]
	game.Workspace.End.SoundId = "rbxassetid://"..newid:tostring()
end

Where in line 5 did I go wrong?

1 answer

✓ Accepted answer

Ok, what you've done here is a simple mistake but you're going about it in the right way, you're using num:tostring() which doesn't do anything to the number, what you need to do is use tostring(num) which will convert the number to string allowing the number to be placed on the end of the string.

ids = {225032798,225032815,225032806,225032853,225032784,225032834,224971324}
function FindEnd()
	newid = ids[math.random(1,#ids)]
	game.Workspace.End.SoundId = "rbxassetid://"..tostring(newid)
end

If this works for you or helped you please vote up and accept this as the answer!

1 comment

0

Thanks for the explanation!

This discussion is preserved as it was. New answers, comments, and votes are closed.