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

Part not appearing?


Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
n = script.Parent

function mold()
	x = Instance.new("Part", game.Workspace)
	x.Name = "Crystal"
	x.Anchored = true
	x.Size = Vector3.new(5, 5, 5)
	x.Friction = 0.4
	x.Shape = "Block"
	x.CFrame = CFrame.new(x.Position,mouse.Hit.p)
end

n.Activated:connect(mold)


This is a localscript which is inside a tool.I want to make a part spawn where the mouse is.Can anyone help me?

4 comments

0

Please use the Code block. It's on the very right of the icons you see above while editing. Paste the script in between the lines that appear. "~~~"

0

Do you have a part in your tool named handle?

0

Nope.

0

If you didn't have a part named Exactly Handle then it will not work. You need a part called Handle for the tool to work. Does the script work then?

1 answer

✓ Accepted answer

-mouse.Hit.p is a Vector3 value. use x.Position instead of x.CFrame. -Consider changing x to local x. -Parts are blocks by default, no need to specify that. -"game.Workspace" can be shortened to "workspace", in case you're feeling lazy. -If you're making a tool (and not a HopperBin), you must have a part in the tool called "Handle".

Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
n = script.Parent

function mold()
	local x = Instance.new("Part", workspace)
    x.Name = "Crystal"
    x.Anchored = true
    x.Size = Vector3.new(5, 5, 5)
    x.Friction = 0.4
    x.Position = mouse.Hit.p
end

n.Activated:connect(mold)

If you truly do not want your tool to have a handle, put this script in a HopperBin, and place the HopperBin in the StarterPack.

Player = game.Players.LocalPlayer
n = script.Parent

function onButton1Down(mouse)
	local x = Instance.new("Part", workspace)
    x.Name = "Crystal"
    x.Anchored = true
    x.Size = Vector3.new(5, 5, 5)
    x.Friction = 0.4
    x.Position = mouse.Hit.p
end

function onSelected(mouse)
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

n.Selected:connect(onSelected)

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