So I found this and it won't work, when I execute the , it doesn't spawn. It is supposed to spawn in front of your players torso. I also added the color, transparency, etc. Please help me?!``
Wall = Instance.new("Part", workspace) Wall.Anchored = true Wall.Position = .Position = Torso.Position + Torso.CFrame.lookVector * 5 Wall.Name = "BigWall" Wall.Size = 50, 50, 10 Wall.Color = "Really Red" Wall.Transparency = 0.3 Wall.CanCollide = true>
There are multiple errors here. I'll highlight them. Correct code is posted at the bottom:
On line 3 of your code, the synax is incorrect. Position requires a Vector3
value. Additonally, you accidently typed ".Position =" again, which will cause it to error.
On line 5 of your code, you set the size of Wall. Size also requires a Vector3
value in order to be correctly set.
On line 6 of your code: The Color
property only takes a Color3
value, instead you can set the color by using BrickColor. An example of doing this would be:
Wall.BrickColor = BrickColor.new("Really Red")
On line 8, there is a less then symbol after true
.
The 2nd arguement of Instance.new is deprecated and should not be used. You should instead set the parent of Wall
by doing Wall.Parent = game.Workspace
.
Your code is improperly indented, you should be using a tab for every function you create. For example, typing if condition then
will have you indent once. You continue this until the function ends.
You should always turn your variables into local by adding a local
infront of them. This is good practice since global variables clutter the enviroment!
Here is your updated code:
-- "Torso" is not defined. Make sure you specify the character! -- If you need help doing this, remove the "--[[" and "-- ]]" --[[ local Torso = game.Workspace["PLAYERNAME"].Torso -- change PLAYERNAME to your player --]] local Wall = Instance.new("Part") Wall.Parent = game.Workspace Wall.Anchored = true Wall.Position = Vector3.new(Torso.Position + Torso.CFrame.lookVector * 5) Wall.Name = "BigWall" Wall.Size = Vector3.new(50, 50, 10) Wall.BrickColor = BrickColor.new("Really Red") Wall.Transparency = 0.3 Wall.CanCollide = true