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

How to make this pad do it's function? Answered

Asked by 10 years ago

First of all, What I am going to make is basically a giver that will be different compared to all the other old ones out there. First of all i'm using a part called Change which will be used to change my Booleanvalue. I have also added a Humanoid check. I think it might not be working because of my Humanoid check. I press play and walk on to my part, nothing happens. I have commented out parts and exchanged with Printing something and still nothing happens, No errors either. Here's the script:

SP = script.Parent



SP.Touched:connect(function(hit)
    local Human_Check = hit.Parent:FindFirstChild("Humanoid")
    if Human_Check ~= nil and SP.BrickColor == ("Bright green") then 
    print("HumanHere")
        SP.BrickColor = BrickColor.new("Bright red")
        SP.Parent.Enable.Value = false
    elseif Human_Check ~= nil and SP.BrickColor == ("Bright red") then
        SP.BrickColor = BrickColor.new("Bright green")
        SP.Parent.Enable.Value = true
    end
end)
0
The part being touched is inside a model. It's already Bright green alphawolvess 1784 — 10y
0
Just noticed doing SP.Enable.Value = false wouldn't do anything because i'll be checking the part thats the parent of the script while Enable is inside of the model. I just fixed this by going Script>Change>Model>Enable and still nothing. alphawolvess 1784 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

The problem is that you are not referring to the colors correctly. Even in if statements, they have to have BrickColor.new before them. Don't worry, it won't add a new color to the brick, even though it sounds like it might.

SP = script.Parent



SP.Touched:connect(function(hit)
    local Human_Check = hit.Parent:FindFirstChild("Humanoid")
    if Human_Check ~= nil and SP.BrickColor ==  BrickColor.new("Bright green") then 
    print("HumanHere")
        SP.BrickColor = BrickColor.new("Bright red")
        SP.Parent.Enable.Value = false
    elseif Human_Check ~= nil and SP.BrickColor == BrickColor.new("Bright red") then
        SP.BrickColor = BrickColor.new("Bright green")
        SP.Parent.Enable.Value = true
    end
end)
0
This works now, and I added a Debounce. I didn't know I had to do that for the BrickColor, but Thank you! alphawolvess 1784 — 10y
Ad

Answer this question