Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 5 years ago

Sorry im super new with scripting help please?

1local Workspace = game:GetService("Workspace")
2 
3Workspace:FindFirstChild("SoundRegions")
4script.Parent.MoveTo("SoundRegions") -- this is the part where I want the parent to move to soundregions

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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:

1local soundRegions = workspace:WaitForChild("SoundRegions") -- I use WaitForChild since it yeilds the script until it loads in
2 
3script.Parent.Parent = soundRegions -- Sets the script's parent to soundRegions
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Hi, few things.

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

you forgot to give it a variable, like so:

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

so to fix up your script completely for you

1local soundregions = workspace:FindFirstChild("SoundRegions")
2script.Parent = soundregions
0
For some reason the script send the itself to sound regions Nistrict 44 — 5y
0
I would have excepted your answer but it was script.Parent.Parent Nistrict 44 — 5y

Answer this question