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

I was making a script where when u activate a tool a new part is created but the script wont work?

Asked by 3 years ago

local tool = script.Parent

function newPart() local part = Instance.new("Part") part.BrickColor = BrickColor.new("Lapis") part.Transparency = 0.6 part.Parent = game.Workspace part.Position = Vector3.new(0, 100, 0) end

tool.Activated:Connect(function(Mouse) Mouse.MouseButton1Down:Connect(function(newPart)

end)

end)

1 answer

Log in to vote
0
Answered by 3 years ago

I've changed up the script a bit, but it should work.

local tool = script.Parent

local function newPart() --[[added "local" before function]]
    local part = Instance.new("Part")
    part.BrickColor = BrickColor.new("Lapis")
    part.Transparency = 0.6
    part.Parent = game.Workspace
    part.Position = Vector3.new(0, 100, 0) 
end

tool.Activated:Connect(function()
    newPart() --[[removed MouseButton1Down thing because the tool is already being activated]]
end)

If it doesn't work, make sure you have a part inside the tool named "Handle".

Ad

Answer this question