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.)
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)