Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Stamper tool code?

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.

1 comment

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.

1 answer

✓ Accepted answer

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.

3 comments

0

It doesn´t works :(

0

is it in a tool and a local script?

0

I just tried it, I dont know why it doesnt work.

This discussion is preserved as it was. New answers, comments, and votes are closed.