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

Does anyone know how I could move a part in workspace into a folder?

Sorry im super new with scripting help please?

local Workspace = game:GetService("Workspace") 

Workspace:FindFirstChild("SoundRegions")
script.Parent.MoveTo("SoundRegions") -- this is the part where I want the parent to move to soundregions

2 answers

✓ Accepted answer

There are some problems with that. 1.) You are using the MoveTo function incorrectly, as it is only for models. 2.) You did not set SoundRegions as a variable so the script does not know what ("SoundRegions") is. Also, you do not have to declare Workspace as a variable, as there is already a variable called workspace built into Roblox Lua. Try this code:

local soundRegions = workspace:WaitForChild("SoundRegions") -- I use WaitForChild since it yeilds the script until it loads in

script.Parent.Parent = soundRegions -- Sets the script's parent to soundRegions

Hi, few things.

  1. you don't need to 'getservice' on workspace for this
  2. when you stated
Workspace:FindFirstChild("SoundRegions")

you forgot to give it a variable, like so:

soundregions = Workspace:FindFirstChild("SoundRegions")
  1. to change the parent, just do
script.Parent = soundregions

so to fix up your script completely for you

local soundregions = workspace:FindFirstChild("SoundRegions")
script.Parent = soundregions

2 comments

0

For some reason the script send the itself to sound regions

0

I would have excepted your answer but it was script.Parent.Parent

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