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

My tool refuses to spawn parts?

I have a script that creates a tool, brings it into the StarterPack, names it, gives it a handle, etc. Everything in the script seems to be working fine, except for the OnActivation() function. What I'm trying to do is, on every mouse-click, a red brick will pop out of the bottom of the Handle of the tool.

tool = Instance.new("Tool")
tool.Parent = game.StarterPack
tool.GripPos = Vector3.new(0,-1.1,0)
tool.Name = "AlphaWand"

handle = Instance.new("Part")
handle.Name = "Handle"
handle.Parent = tool
handle.Size = Vector3.new(1,4,1)

handleBlockmesh = Instance.new("BlockMesh")
handleBlockmesh.Parent = handle
handleBlockmesh.Scale = Vector3.new(0.5,1,0.5)

local waitForTools = game.StarterPack:WaitForChild("AlphaWand")

function onActivated()
	local df = Instance.new("Part")
	df.Parent = game.Workspace
	df.Name = "DROPFLARE"
	df.BrickColor = BrickColor.new("Bright red")
	df.Position = tool.Handle.Position
	df.Anchored = false
	df.CanCollide = false
	df.Size = Vector3.new(1,2,1)
end

tool.Activated:connect(onActivated)

I've tried an if statement, so it checks to see if a brick under the name "DROPFLARE" is nil, and if it is, the output would print "Couldn't find flare". Apparently, that didn't work. I'm stumped here.

1 answer

The event Activated is for Hopperbins ,Use the Equipped event.

tool = Instance.new("Tool")
tool.Parent = game.StarterPack
tool.GripPos = Vector3.new(0,-1.1,0)
tool.Name = "AlphaWand"

handle = Instance.new("Part")
handle.Name = "Handle"
handle.Parent = tool
handle.Size = Vector3.new(1,4,1)

handleBlockmesh = Instance.new("BlockMesh")
handleBlockmesh.Parent = handle
handleBlockmesh.Scale = Vector3.new(0.5,1,0.5)

local waitForTools = game.StarterPack:WaitForChild("AlphaWand")

function onActivated()
    local df = Instance.new("Part")
    df.Parent = game.Workspace
    df.Name = "DROPFLARE"
    df.BrickColor = BrickColor.new("Bright red")
    df.Position = tool.Handle.Position
    df.Anchored = false
    df.CanCollide = true
    df.Size = Vector3.new(1,2,1)
end

tool.Equipped:connect(onActivated)


1 comment

0

It spawns a brick, I assume (from the small, quick freeze every time I click with it in my hand), but I just can't see the brick at all. I checked the Workspace while I was spawning some of the flares, and there weren't any listed there

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