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

My tool refuses to spawn parts?

Asked by 9 years ago

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

Log in to vote
1
Answered by
woodengop 1134 Moderation Voter
9 years ago

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)


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 undeadgamer55 0 — 9y
Ad

Answer this question