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

Why won't this OnChatted script work?

I am trying and trying, it just won't work. I'm not sure what is wrong. I have the lighting objects correct , it's the script that's failing

Why won't it work?

admin = { "FergotCheese","StargateOne" }
game.Players.PlayerAdded:connect(function(nP)
for _,v in pairs(admin) do
if nP.Name == v then
nP.Chatted:connect(function(msg)
if msg == "Run/Aim" then
x = game.Lighting.Aim:Clone()
M = Instance.new("Hint")
M.Parent = game.Workspace
M.Text = "Ran Aim"
wait(0.1)
x.Parent = game.Workspace
wait(3)
M:Remove()
end
end)
end
end
end)

if msg == "End/Aim" then
M = Instance.new("Hint")
M.Parent = game.Workspace
M.Text = "Ended Aim"
game.Workspace.Aim:Remove()
wait (1)
M:Remove()
end
end)
end
end
end)

1 answer

admin = { "FergotCheese","StargateOne" }

function isAdmin(plrname)
	for _,v in pairs(admin) do
		if plrname == v then
			return true
		end
	end
	return true
end

game.Players.PlayerAdded:connect(function(nP)
	if isAdmin(nP.Name) then
		nP.Chatted:connect(function(msg)
			if msg == "Run/Aim" then
				x = game.Lighting.Aim:Clone()
				M = Instance.new("Hint")
				M.Parent = game.Workspace
				M.Text = "Ran Aim"
				wait(0.1)
				x.Parent = game.Workspace
				Game:GetService("Debris"):AddItem(M, 3) -- add M to debris, and remove after 3 seconds
			end

			if msg == "End/Aim" then
				M = Instance.new("Hint")
				M.Parent = game.Workspace
				M.Text = "Ended Aim"
				game.Workspace.Aim:Remove()
				Game:GetService("Debris"):AddItem(M, 1) -- add M to debris, and remove after 1 second
			end
		end)
	end
end)

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