So 1 or 2 weeks ago I had trouble scripting a stamper tool, what I want to do is that when you have to tool and you click on the floor it will make a brick. Heres the script so far:
1 | function onClicked(playerWhoClicked) |
2 | local brick = Instance.new( "Part" , game.Workspace) -- Creating the brick, and placing it into the Workspace |
3 | brick.Name = "NewBrick" -- This name has to correspond with the name of your brick on the map |
4 | brick.Size = Vector 3. new( 10 , 10 , 10 ) -- This is the size to which you want to change your brick |
5 | end |
6 |
7 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
I also thought of putting a sample brick on lighting and when you click it will clone the brick and put it on workspace I will work on that later.
Why is this in a clickdetector if you want to make the part it should be in a tool? Use mouse.Hit to place the part. Example:
01 | tool = script.Parent |
02 | tool.Equipped:connect( function (mouse) --Fires event when tool is equipped |
03 | mouse.Button 1 Down:connect( function () |
04 | player = game.Players:GetPlayerFromCharacter(tool.Parent) --Gets player |
05 | local part = Instance.new( "Part" ,Workspace) --Makes a new part in Workspace |
06 | part.FormFactor = "Custom" --Sets part`s formfactor to custom to make a certain size |
07 | part.Size = Vector 3. new( 10 , 10 , 10 ) --Sets size |
08 | part.Position = mouse.Hit.p --Uses mouse.Hit.p (3D CFrame position) to position the part |
09 | part.Name = player.Name.. "_Brick" --Makes the part`s name the player`s name then _Brick |
10 | end ) |
11 | end ) --Ends event |
This is just an example, but if you want to use it it`s okay just edit it, put it in a local script in order to work.