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 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 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:

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
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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
0
For some reason the script send the itself to sound regions Nistrict 44 — 4y
0
I would have excepted your answer but it was script.Parent.Parent Nistrict 44 — 4y

Answer this question