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