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

What is wrong with this script?

Asked by 10 years ago

Here is the script I made.. I don't know why it doesn't work:

Brick = script.Parent
AnotherBrick = game.Workspace.TP

if game.Workspace.Screen.Brickcolor.Name == "Bright green"
    then 
    Brick.Touched:connect(function(part)
    if part.Parent.Humanoid then -- *
        if part.Parent.Humanoid.Health > 0 then
            part.Parent:MoveTo(AnotherBrick.Position)
        end
    end
end)
0
Mind putting it in code block? ultrabug 306 — 10y
0
Oh, sorry, sure DrCylonide 158 — 10y
0
Okay, it's in code block DrCylonide 158 — 10y

1 answer

Log in to vote
0
Answered by
Tesouro 407 Moderation Voter
10 years ago

There is a end missing and it's BrickColor, with capital c. So it would be like this:

Brick = script.Parent
AnotherBrick = game.Workspace.TP

if game.Workspace.Screen.BrickColor.Name == "Bright green" then
    Brick.Touched:connect(function(part)
        if part.Parent.Humanoid then
            if part.Parent.Humanoid.Health > 0 then
                part.Parent:MoveTo(AnotherBrick.Position)
            end
        end
    end)
end

A hint: use http://wiki.roblox.com/index.php?title=Output, it's really useful to find out what is wrong in your code. Run the script and check output to see if nothing is wrong.

Edit:

Ok, I tried it in studio and worked perfectly. Just changed a line here to make more sense:

Brick = script.Parent
AnotherBrick = game.Workspace.TP

Brick.Touched:connect(function(part)
    if game.Workspace.Screen.BrickColor.Name == "Bright green" then -- more useful inside the function
        if part.Parent:FindFirstChild("Humanoid") then -- this will look after humanoid, if the part isn't a character part, it won't break the script
            if part.Parent.Humanoid.Health > 0 then
                part.Parent:MoveTo(AnotherBrick.Position)
            end
        end
    end
end)
0
Maybe the if statement about Humanoid have problems, but check out output first. Tesouro 407 — 10y
0
I got this in the output (didn't work): Attempt to connect failed: Passed value is not a function DrCylonide 158 — 10y
0
Weird. What line? Tesouro 407 — 10y
0
Not sure.. how do I tell? DrCylonide 158 — 10y
View all comments (2 more)
0
isn't it written in there? like "Script 'Workspace.Script', Line 1" Tesouro 407 — 10y
0
I can't find it.. :P DrCylonide 158 — 10y
Ad

Answer this question