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

I found this brick script that is supposed to spawn in front of LocalPlayer's torso. Help?

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> 

1 answer

✓ Accepted answer

There are multiple errors here. I'll highlight them. Correct code is posted at the bottom:

###Incorrect syntax

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.

###Instance.new

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.

###Indentation

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.

###local variables

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

6 comments

0

One correction. Bricks do now have the Color property.

0

Yes they do

0

Edited, thanks

0

It spawns INSIDE the character, not in front of it.

0

That's your fault. This is the exact code YOU wrote.

0

ok

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