Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wallWidth = 60
- wallHeight = 25
- brickSpeed = 0.01
- brickWidth = 6
- brickHeight = 4
- brickDepth = 2
- colors = {BrickColor.new("Medium Blue"), BrickColor.new("Pastel light blue"), BrickColor.new("Light blue"), BrickColor.new("Cyan"), BrickColor.new("Pastel blue")}
- debris = game:GetService("Debris")
- local Tool = script.Parent
- function staffUp()
- Tool.GripForward = Vector3.new(0,0,-1)
- Tool.GripRight = Vector3.new(1,0,0)
- Tool.GripUp = Vector3.new(0,1,0)
- end
- function staffOut()
- Tool.GripForward = Vector3.new(.0976, .00976, -.995)
- Tool.GripRight = Vector3.new(.195, -.981, .00952)
- Tool.GripUp = Vector3.new(.976, .195, .0976)
- end
- -- places a brick at pos and returns the position of the brick's opposite corner
- function placeBrick(cf, pos)
- local brick = Instance.new("Part")
- brick.Size = Vector3.new(brickWidth, brickHeight, brickDepth)
- brick.BrickColor = colors[math.random(1, #colors)]
- brick.Friction = .01
- brick.CFrame = cf * CFrame.new(pos + brick.size / 2)
- if ( math.random() > .5) then
- brick.Material = Enum.Material.Ice
- else
- brick.Transparency = .1 + (math.random(1,4) / 10)
- end
- brick.Parent = game.Workspace
- brick:makeJoints()
- debris:AddItem(brick, 120)
- return brick, pos + brick.size
- end
- function buildWall(cf)
- local bricks = {}
- assert(wallWidth>0)
- local y = 0
- while y < wallHeight do
- local p
- local x = -wallWidth/2
- while x < wallWidth/2 do
- local brick
- brick, p = placeBrick(cf, Vector3.new(x, y, 0), color)
- x = p.x
- table.insert(bricks, brick)
- wait(brickSpeed)
- end
- y = p.y
- end
- return bricks
- end
- function snap(v)
- if math.abs(v.x)>math.abs(v.z) then
- if v.x>0 then
- return Vector3.new(1,0,0)
- else
- return Vector3.new(-1,0,0)
- end
- else
- if v.z>0 then
- return Vector3.new(0,0,1)
- else
- return Vector3.new(0,0,-1)
- end
- end
- end
- Tool.Enabled = true
- function onActivated()
- if not Tool.Enabled then
- return
- end
- Tool.Enabled = false
- local character = Tool.Parent;
- local humanoid = character.Humanoid
- if humanoid == nil then
- print("Humanoid not found")
- return
- end
- local targetPos = humanoid.TargetPoint
- local lookAt = snap( (targetPos - character.Head.Position).unit )
- local cf = CFrame.new(targetPos, targetPos + lookAt)
- if (targetPos - character.Torso.Position).magnitude < 64 then
- staffOut()
- Tool.Handle.UseSound:Play()
- buildWall(cf)
- staffUp()
- wait(5)
- end
- Tool.Enabled = true
- end
- script.Parent.Activated:connect(onActivated)
- local Tool = script.Parent;
- function UpdateIcon(mouse)
- if (mouse == nil) then return end
- if (Tool.Enabled == true) then
- mouse.Icon = "rbxasset://textures\\GunCursor.png"
- else
- mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
- end
- end
- function onButton1Down(mouse)
- UpdateIcon(mouse)
- end
- function onEquippedLocal(mouse)
- UpdateIcon(mouse)
- end
- Tool.Equipped:connect(onEquippedLocal)
Add Comment
Please, Sign In to add comment