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

Stamper tool code?

Asked by 10 years ago

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:

function onClicked(playerWhoClicked)
   local brick = Instance.new("Part", game.Workspace) -- Creating the brick, and placing it into the Workspace
brick.Name = "NewBrick" -- This name has to correspond with the name of your brick on the map
brick.Size = Vector3.new(10, 10, 10) -- This is the size to which you want to change your brick
end

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.

0
-1 Point really? just because you can´t solve something you don´t have to steal me points, I think I explained myself clearly. biocommand 30 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

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:

tool=script.Parent
tool.Equipped:connect(function(mouse) --Fires event when tool is equipped
    mouse.Button1Down:connect(function()
        player=game.Players:GetPlayerFromCharacter(tool.Parent) --Gets player
        local part=Instance.new("Part",Workspace) --Makes a new part in Workspace
        part.FormFactor="Custom" --Sets part`s formfactor to custom to make a certain size
        part.Size=Vector3.new(10,10,10) --Sets size
        part.Position=mouse.Hit.p --Uses mouse.Hit.p (3D CFrame position) to position the part
        part.Name=player.Name.."_Brick" --Makes the part`s name the player`s name then _Brick
    end)
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.

0
It doesn´t works :( biocommand 30 — 10y
0
is it in a tool and a local script? 73epic311 13 — 10y
0
I just tried it, I don`t know why it doesn`t work. 73epic311 13 — 10y
Ad

Answer this question