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

Part isn't a valid member of Workspace??

Asked by 3 years ago

I am a new scripter and I wanna try this out and it seems to not find part in workspace

local part = game.worksapce
local part2 = part.Part2

if part.parent == game.workspace then
part2:Clone().parent = part
end

any help is appreciated

0
Major issue in Capitalization and Misspelled words DuckyRobIox 280 — 3y

3 answers

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Please be sure when getting a game's service, such as workspace, it's recommended by me that you use game:GetService("Service Name") to do it. This is so that you avoid any issues with services being renamed or configured in an inaccessibly way.

Here's a little rewrite in return.

local Workspace = game:GetService("Workspace")
local Part2 = Workspace:FindFirstChild("Part2") -- Use this if you're waiting for the part: Workspace:WaitForChild("Part2")

if Part2.Parent == Workspace then
    Part2:Clone().Parent = Workspace
end
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Alright so there are a few problems in your script going with capitalization and misspelled Words

Heres your current script

local part = game.worksapce--Workspace is misspelled and the W should be capitalized 
local part2 = part.Part2

if part.parent == game.workspace then -- Workspace should be capitalized and Parent aswell
part2:Clone().parent = part --Parent should be capitalized aswell
end

I wont redo the code for you or else that would be doing it for you I hope this helps accept if it does

0
o tylerl96 8 — 3y
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Look i fixed it, your errors were capitalization. Try this one!

local part2 = game.Workspace:FindFirstChild("Part2") -- or :WaitForChild("Part2")

if part.Parent == game.Workspace then
    part2:Clone().Parent = game.Workspace
end

Also set the position because it's gonna clone anywhere! Hope this helps, and have fun learning! :D

Answer this question