Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
-1

Part not appearing?

Asked by 5 years ago

~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

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?

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. "~~~" alphawolvess 1784 — 5y
0
Do you have a part in your tool named handle? M39a9am3R 3209 — 5y
0
Nope. brokenrares 48 — 5y
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? alphawolvess 1784 — 5y

1 answer

Log in to vote
0
Answered by
funyun 960 Moderation Voter
5 years ago

-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)
Ad

Answer this question