So, I've been making this script for about a month now. I'm constantly changing things and trying to make it better. Today, however, I tried to add something extra. Here's the code:
local part = script.Parent
local db = false
local myVar = game.Workspace.Pro.SurfaceGui.Test
local Alarm = game.Workspace.Alarm1
local myArray = {"Ultra-Fabulous Hair", "EpicWings", "NinjaTwinSwords", "DOGE", "Snake Eyes", "GlassesBlackFrame", "Americasweetheart"}
function FindHat(hit)
local hat = hit.Parent:FindFirstChild(myArray[1]) or (myArray[2])
local human = hit.Parent:FindFirstChild("Humanoid")
if not db then
if human and hat then
db = true
Alarm.Noise:Play()
myVar.Text = ("HOW DARE YOU WEAR THAT WRETCHED HAT!?")
wait(3)
myVar.Text = ("YOU WILL BE SMITED BY MY WRATH!")
wait(3)
myVar.Text = ("DIE!!")
wait(2)
human.MaxHealth = 0
wait(5)
myVar.Text = (" ")
game.Workspace.Alarm1.Noise:Stop()
db = false
else
myVar.Text = ("You're good to go!")
wait(3)
myVar.Text = (" ")
end
end
end
part.Touched:connect(FindHat)
Even though I'm not wearing these hats, the whole script runs on anyway. So, I reversed it and deleted:
local myArray = {"Ultra-Fabulous Hair", "EpicWings", "NinjaTwinSwords", "DOGE", "Snake Eyes", "GlassesBlackFrame", "Americasweetheart"}
and also changed
local hat = hit.Parent:FindFirstChild(myArray[1]) or (myArray[2])
to
local hat = hit.Parent:FindFirstChild("NameOfHat")
So, it started working again normally. Any ideas or suggestions as to why it didn't work with the previous parts?

2 comments
This script took you a month to create?
I've been working on for 1 month. I'm learning scripting by using what I learn, and practicing it into one big script. If I find I can't insert certain parts, I make a new script. I'm new to all this. I've only been practicing scripting for about 2 months. This script here took a month to make it end up where it is right now. I keep changing things in it.