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

Try to make script execute after a Sound has been added to workspace?

local children = game.Workspace.sikshit:GetChildren()
local song = game.Workspace.Sound


while wait() do
	for i, v in pairs(children) do
		v.Size = Vector3.new(0.23,2.15,song.PlaybackLoudness/30)
	end
end

2 comments

0

Add context. What are you trying to do.

0

So this script changes bricks in a model name "sikshit" to resize to the music and it used to work with a music player but now i want it to work with admin commands when music is played with a command :music xxxxxxxxxx

1 answer

To detect when an object has been added to the workspace, we can use the ChildAdded event of Workspace. In your context, it can be used like so:

local children = game.Workspace.sikshit:GetChildren()
local song = game.Workspace.Sound

workspace.ChildAdded:Connect(function(Child)
	if Child:IsA("Sound") then
		song = Child
	end
end)

while wait() do
    for i, v in pairs(children) do
        v.Size = Vector3.new(0.23,2.15,song.PlaybackLoudness/30)
    end
end

Please note I wrote this in the ScriptingHelper's textbox, so excuse any minor errors.

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