So basically I am trying to make it so that when a player presses E then a big wall appears ten studs in front of them in the direction they are facing please give me tips or if you have time give me an explaination because I am actually trying to understand codes I put in my game
local uis = game:GetService('UserInputService') local wall = game.Workspace.MassiveMudWall.Part local player = game.Players.LocalPlayer local useStatus = false local usePosition = player.Character.Position uis.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then print('Point1') local massiveMudWall = Instance.new(brick, game.Workspace.MassiveMudWall) massiveMudWall.Size = 31, 31, 2 massiveMudWall.Position = -18.5, 15.5, (usePosition + 5) wait(5) massiveMudWall:Destroy() end end)
The problem is that you aren't using the right data types. You have not used Vector3.new() to put position or size. Do this instead:
local uis = game:GetService('UserInputService') local wall = game.Workspace.MassiveMudWall.Part local player = game.Players.LocalPlayer local useStatus = false local usePosition = player.Character.Position uis.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then print('Point1') local massiveMudWall = Instance.new(brick, game.Workspace.MassiveMudWall) massiveMudWall.Size = Vector3.new(31, 31, 2) massiveMudWall.Position = Vector3.new(-18.5, 15.5, (usePosition + 5)) wait(5) massiveMudWall:Destroy() end end)
To be honest. I'm surprised you did not notice any errors in your output.
Man, there is a lot much wrong with this, in a lot of different ways. First of all, Characters do not have a position value so line 7 would error. You should use the position of their head instead. Next, line 12 would not work because brick is not a type of instance. Third of all line 13 and 14 would not work because it should be vector3 values. And then on top of all of that, you should be using CFrame instead of Positions. Here is what the script should look like. Mess around with the CFrame value of line 15 to your liking.
local uis = game:GetService('UserInputService') local wall = game.Workspace.MassiveMudWall.Part local player = game.Players.LocalPlayer local useStatus = false uis.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then if useStatus == true then useStatus = false print('Point1') local massiveMudWall = wall:Clone() massiveMudWall.Parent = wall.Parent massiveMudWall.Size = Vector3.new(31, 31, 2) massiveMudWall.CFrame = player.Character.Head.CFrame * CFrame.new(0,0,-30) wait(5) useStatus = true massiveMudWall:Destroy() end end end)