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

Make a brick's rotation the rotation of the player:

Asked by 10 years ago

this is my script so far:

Player = script.Parent.Parent
mouse = Player:GetMouse()

function onKeyDown(key)
    Key = key:lower()
    if Key == "r" then
        x = Instance.new("Part")
        x.BrickColor = BrickColor.new("Reddish brown")
        x.Size = Vector3.new(8,1,8)
        x.Anchored = true
        x.TopSurface = "Smooth"
        x.BottomSurface = "Smooth"
        x.Material = "Brick"
        x.Parent = Workspace
        x.CFrame = Player.Character.Torso.CFrame *CFrame.new(0,0,-5)
        x.Rotation = Vector3.new(Player.Character.Torso.Rotation)
        game.Debris:AddItem(x,3)
    end
end


mouse.KeyDown:connect(onKeyDown)

Effectively i'm trying to make a wall that faces you.

0
Update this question with the Code Block button and put your code inside of that. Unclear 1776 — 10y

1 answer

Log in to vote
1
Answered by
Kratos232 105
10 years ago

OK, at first your script started off good, but then you got to the CFrame part... You see, CFrame includes rotation, so the next line with Rotation was unnecessary, and should just be removed. And your size is completely wrong. When changing sizes with Vector3.new it goes like this: Vector3.new(xSize, ySize, zSize) and since you wanted a wall, it would've made a square kinda on the ground, because the ySize is height, and you put it as 1. What it should be is this:

x.Size = Vector3.new(8, 8, 1)

And the game.Debris part... Unless Debris is actually IN game, you should change it to

Game:GetService("Debris"):AddItem(x, 3)

Here's the script FIXED.

Script:


Player = script.Parent.Parent mouse = Player:GetMouse() function onKeyDown(key) Key = key:lower() if Key == "r" then x = Instance.new("Part") x.BrickColor = BrickColor.new("Reddish brown") x.Size = Vector3.new(8, 8, 1) x.Anchored = true x.TopSurface = "Smooth" x.BottomSurface = "Smooth" x.Material = "Brick" x.Parent = Workspace x.CFrame = Player.Character.Torso.CFrame *CFrame.new(0,0,-5) Game:GetService("Debris"):AddItem(x, 3) end end mouse.KeyDown:connect(onKeyDown)

Well, I hope I helped.

  • Kratos232
Ad

Answer this question