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

Line 23 Problem?

Asked by
Resnex 60
10 years ago
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

Log in to vote
0
Answered by
lomo0987 250 Moderation Voter
10 years ago
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

0
Even afterwards, it lists: Attempt to connect failed: Passed value is not a function - Script 'Workspace.Lokie.Script', Line 23 Resnex 60 — 10y
0
I just edited it, try that now. lomo0987 250 — 10y
0
Still won't work, lists the same problem.. Resnex 60 — 10y
0
Can you put some prints in there and see where it gets to? lomo0987 250 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Your line 23 is supposed to be stated like this:

script.Parent.Touched:connect(onTouch)
Log in to vote
0
Answered by 10 years ago
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

Answer this question