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

Line 23 Problem?

function onTouched(part)
    if part.Name == "Bullet" or "Paintball" then
        Shield = Instance.New("Part")
        Shield.Size = Vector3.new(.2,.2,.2)
        Shield.CanCollide = false
        Shield.Parent = game.Workspace
        Shield.BrickColor = ("Really red")
        Shield.Position = script.Parent

        mesher = Instance.new("BlockMesh")
        mesher.Parent = Shield
        mesher.Scale = Vector3.new(0.2, 0.2, (script.Parent.Position - onTouched(part).Position).magnitude)

        explosion = Instance.new("Explosion")
        explosion.Parent = game.Workspace
        explosion.Position = Touched(part)

        wait(.5)
        part:remove()
		print("WORKING!!")
    end
end
script.Parent.Touched:connect(Part)

I looked at output in Testing, and it said that: " Attempt to connect failed: Passed value is not a function"

Anyone know what I'm doing wrong?

3 answers

function onTouched(part)
    if part.Name == "Bullet" or "Paintball" then
        Shield = Instance.New("Part")
        Shield.Size = Vector3.new(.2,.2,.2)
        Shield.CanCollide = false
        Shield.Parent = game.Workspace
        Shield.BrickColor = ("Really red")
        Shield.Position = script.Parent

        mesher = Instance.new("BlockMesh")
        mesher.Parent = Shield
        mesher.Scale = Vector3.new(0.2, 0.2, (script.Parent.Position - onTouched(part).Position).magnitude)

        explosion = Instance.new("Explosion")
        explosion.Parent = game.Workspace
        explosion.Position = Touched(part)

        wait(.5)
        part:remove()
        print("WORKING!!")
    end
end
script.Parent.Touched:connect(onTouched) -- Just edited this again.

Now try it. I was looking through the wiki and I didn't see anything for that.. I was looking here: http://wiki.roblox.com/index.php/Basic_Scripting

4 comments

0

Even afterwards, it lists: Attempt to connect failed: Passed value is not a function - Script 'Workspace.Lokie.Script', Line 23

0

I just edited it, try that now.

0

Still won't work, lists the same problem..

0

Can you put some prints in there and see where it gets to?

Your line 23 is supposed to be stated like this:

script.Parent.Touched:connect(onTouch)
function onTouched(part)
    if part.Name == "Bullet" or part.Name == "Paintball" then -- Add part.Name ==
        Shield = Instance.New("Part", Workspace) -- Add Parent here
        Shield.Size = Vector3.new(.2,.2,.2)
        Shield.CanCollide = false
        Shield.BrickColor = BrickColor.new("Really red") --BrickColor.new
        Shield.CFrame = script.Parent.CFrame -- No Position Its CFrame
 
        mesher = Instance.new("BlockMesh", Shield) -- Parent here
        mesher.Scale = Vector3.new(0.2, 0.2, (script.Parent.Position - onTouched(part).Position).magnitude)
 
        explosion = Instance.new("Explosion", Workspace) -- Parent here
        explosion.CFrame = part.CFrame --Position = CFrame
 
        wait(.5)
        part:remove()
        print("WORKING!!")
    end
end

script.Parent.Touched:connect(part) -- No Maj on the p

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