Why isn't this script working?

Why isn’t this script working?
So, the point of these scripts are: The player is supposed to be awarded a badge IF a part (that is inside a folder) is a certain color. And so I have a part, that if touched it will detect whether or not a certain part is that color. If it is that certain color, then the script in the badge awarder part will be “un-” disabled.

(The script in the badge awarder part is set to disable.)

But it just won’t work, and I’ve been doing everything correctly I think. It awards the player the badge whether or not the part is that certain color.

Here are the scripts:
The part that un-disables the script inside the badge awarder part, if another certain part is a certain color.

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid")then
		if game.Workspace.FactoryLasers.LaserButton.BrickColor == "Really red" then
			game.Workspace.NoLazerBadge.Script.Disabled = false
		
		end
	end
end)

The script (that is disabled) that gives the player the badge

local badgeservice = game:GetService("BadgeService")
local id = 2124597577 --Type here the Badge ID, you can get it from the link of the Badge 

script.Parent.Touched:Connect(function(hit)

	if hit.Parent:FindFirstChild("Humanoid")then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)

		if plr then
			badgeservice:AwardBadge(plr.UserId,id)
		end
	end
end)

Am I doing anything wrong? Why won’t it work? (Please explain in the most simplest terms since I am not that familiar/good with scripting.)

1 Like

Your problem is the line that’s checking if the brick color is “Really Red”, it doesn’t work like that.

Try this:

if game.Workspace.FactoryLasers.LaserButton.BrickColor == BrickColor.Red() then
1 Like

I believe you’d need to change the value that is being checked for from BrickColor.Red() to BrickColor.new("Really Red").


BrickColor Documentation

BrickColor Codes Documentation

1 Like

You’re right, assumed BrickColor.Red() was Really Red

@StrongBigeMan9 @jigwv

I tried both of those lines of code, but it still won’t work. :confused:

Actually, you can do this as well:

if Color == BrickColor.new('Really red') then
   -- Code.
end

Hiya! I’m not sure of this is what you need, but I wrote out some code that might help. If it isn’t what you need, just let me know, and I’ll try my best to help you!

local BadgeService = game:GetService("BadgeService")
local BadgeId = 000000
local Part = script.Parent
local debounce = false
local Part2 = game.Workspace.Folder.Part -- Part in the folder.

Part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
		

		local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
		debounce = true

		if Part2.BrickColor == BrickColor.new("Really red") then
			BadgeService:AwardBadge(Player.UserId, BadgeId)
		end
        wait(1)
        debounce = false
	end
end)
3 Likes

That works!

Thank you so much!! :smiley:

1 Like

No worries! Good luck developing!

1 Like