# A Wall Which Follows Player

So, my game is a 2D game and I want to make it so that a wall follows the x and y coordinates of a player. The reason I am doing this is so that the player doesn’t fall off the map. Why can’t I just put a normal wall? Well, I can’t put a normal wall because in the block placement system I am using it doesn’t work if there is a part in the way, even when it is transparent, so I want to make it so that the player can’t fall off as well as the player being able to place blocks.

Create a local part.
Parent it to workspace.
In a while true do loop, set the Position to the HumanoidRootPart’s X and Y, and have it at the correct Z.
Then, at the end of the loop, use task.wait().
Then end the loop with ‘end’.

But, I don’t really know how to do that. I’m new to scripting.

https://developer.roblox.com/en-us/api-reference/property/BasePart/Position

Can you explain to me how to do this for my situation? Because I don’t know how to do it.

I have already explained it to you, and I have given you the necessary resources.

Also, see Variables. This explains how to set values. (This includes Vector3. Vector3 is just saying a 3 dimension position.)

Also, is there a way to make it so that a player can’t cross a border without using a part?

Detect when a player goes past a certain point without permissions, and prevent them from going further, either with a VectorForce, AlignPosition (i think?) or just set their position (very choppy). VectorForce and AlignPosition are in devhub.

I put this as a local script in StarterPlayerScripts, but it didn’t work:

``````while wait(0.001) do
local Player = game.Players.LocalPlayer
local Position = Player.Character.UpperTorso.Position

Position = Vector3.new(Position.X, Position.Y, -479.173)
end
``````

while true do wait(), not while wait (0.001) do.

Also, output?

This is the edited script:

``````while true do wait()
local Player = game.Players.LocalPlayer
local Position = Player.Character.UpperTorso.Position

Position = Vector3.new(Position.X, Position.Y, -479.173)
end
``````

Output:

``````local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Torso = Character.UpperTorso or Character:WaitForChild("UpperTorso")

while Character ~= nil do
local Position = Torso.Position
-- the rest of the script
end
``````

sadly you will have to add checks to make sure the player and it’s parts are really there. I would recommend gathering your parts before looping over them often

Also use `task.wait()` it supersedes `wait()` but most tutorials are not up to date

It still isn’t working for some reason, here is the script:

``````local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Torso = Character.UpperTorso or Character:WaitForChild("UpperTorso")

while Character ~= nil do
local Position = Torso.Position
Position = Vector3.new(Position.X, Position.Y, -479.173)
end
``````

Why isn’t it working, do you have any more of the output log to show?

right I forget it just errors when using dot notation, just use `WaitForChild`
`local Torso = Character:WaitForChild("UpperTorso")`

No, it doesn’t work this is a local script in StarterPlayerScripts:

``````local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Torso = Character:WaitForChild("UpperTorso")

while Character ~= nil do