To be specific, I've got this code I've been working on for a few days, and I'm adding some finishing touches. Here it is:
local part = script.Parent
local db = false
local myVar = game.Workspace.Part.SurfaceGui.Test
local Alarm = game.Workspace.Alarm
local x = 0
function FindHat(hit)
local hat = hit.Parent:FindFirstChild("SnipersVisor")
local human = hit.Parent:FindFirstChild("Humanoid")
if not db then
if human and hat then
db = true
Alarm.Noise:Play()
while x < 10 do
Alarm.BrickColor = BrickColor.new("Really red")
wait(0.5)
Alarm.BrickColor = BrickColor.new("White")
x = x+1
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(3)
myVar.Text = (" ")
game.Workspace.Alarm.Noise:Stop()
end
db = false
else
myVar.Text = ("You're good to go!")
wait(2)
myVar.Text = (" ")
end
end
end
part.Touched:connect(FindHat)
Everything works, except the "while" part. I want the brick to change colors, while the text changes on the GUI. On top of it, it loops alot of times. And I know there's an "end" missing to finish the loop, but when I add it, nothing works. Any help, please?

1 comment
You choose a terrible answer in your last question. This is your fault.