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

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

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)

2 comments

0

The part being touched is inside a model. It's already Bright green

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.

1 answer

✓ Accepted answer

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)

1 comment

0

This works now, and I added a Debounce. I didn't know I had to do that for the BrickColor, but Thank you!

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